[FFmpeg-user] More on audio stream mapping

dE . de.techno at gmail.com
Sat Dec 17 14:30:36 CET 2011

On 12/17/11 14:38, Clément Boesch wrote:
> On Fri, Dec 16, 2011 at 12:11:50PM +0000, Tim Nicholson wrote:
>> I have a file containing 1 video and 4 mono audio streams, and wish
>> to create a file with 1 video and 2 stereo audio streams.
>> Under the old API the extra audio stream was added after the output
>> filename, but now it is supposed to be done via the -map and
>> -map_channel commands.
>> It therefore seems that the correct way to now achieve this is:-
>> ffmpeg -i archive.gxf -c:v copy \
>> -c:a libfaac -b:a 96k -ar 48k \
>> -map 0:0 -map 0:1 -map 0:2 \
>> -ac 2 -map_channel 0.1.0:0.1 -map_channel 0.2.0:0.1 \
>> -ac 2 -map_channel 0.3.0:0.2 -map_channel 0.4.0:0.2 \
>> out.mp4
>>  From my reading of the documentation the:-
>> -map 0:0 -map 0:1 -map 0:2
>> maps the video and first two audio streams to the output file, which
>> is not the mapping I actually want but is the only way I can see to
>> add the extra output audio stream. Then the:-
>> -map_channel 0.1.0:0.1
>> commands overwrite this mapping to put the audio channels where I want them.
>> Adding streams by performing a mapping that is not wanted seems to
>> me to be counter intuitive. Or have I misunderstood things?
>> It also appears that you cannot use -c:a copy if using -map_channel
>> as the copy copies the stream as is, and not the channel.
> You can't unfortunately ATM have an output stream composed of multiple
> input streams (internally an output stream is associated with only one
> input stream); I though I added a note in the documentation, but my
> wording is certainly approximative as ever.
> But this might be possible through the filters when the merge filter will
> be upstream (there is a pending patch on the mailing list). One could also
> write some stream preprocessing code to merge the streams.
> Anyway, you just hit a limitation...
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Also you may extract the multichannel audio first, then merge it using 
an audio editor like audacity -- that can export all channels to 2 tracks.

After exporting from audacity, you can merge it to the video using ffmpeg.

More information about the ffmpeg-user mailing list