[FFmpeg-user] complicated audio channel mapping
Gász Zoltán
zoz at sch.bme.hu
Wed Jan 30 21:54:10 CET 2013
Hello!
Someone on ffmpeg forum suggested to pop my question here, so :)
I was using ffmbc to convert some strange audio mapped files into
some... nice ones.
For example my input file has 8 audio channels, but in a strange way. It
has 4 streams:
1st stream: 2 channels
2nd stream: 1 channel
3rd stream: 1 channel
4th stream: 4 channel
Now, let's say I want 2 channel audio streams on the output (4 of them)
So when using ffmpeg, the mapping looks like this:
-map_audio_channel 0:1:0:0:1:0
-map_audio_channel 0:1:1:0:1:1
-map_audio_channel 0:2:0:0:2:0
-map_audio_channel 0:3:0:0:2:1
-map_audio_channel 0:4:0:0:3:0
-map_audio_channel 0:4:1:0:3:1
-map_audio_channel 0:4:2:0:4:0
-map_audio_channel 0:4:3:0:4:1
About the ffmbc syntax:
The first 3 numbers are identifying the input channel, the 2nd 3 numbers
the output channel.
So: 0th input file 1th stream 0th channel goes to 0th output file 1th
stream (0th is video) 0th channel, etc.
...and at the end of the param list as many "newaudio" strings as many
output streams you want, minus 1 (1 is created by defaut), on in this
case: "newaudio newaudio newaudio"
So far so good, this worked perfectly, but
*How do I do this with ffmpeg?*
In this particular case the solution would be:
1. map the 1st stream as is to the output's first stream, no problem
-map 0:1
2. use amerge to merge the 2nd and 3rd streams and label it "mylabel",
map "mylabel" to the output's 2dn stream
-filter_complex "[0:2] [0:3] amerge=inputs=2 [mylabel]"
-map [mylabel]:0.2
3. map the 3rd input stream to the 3rd and the 4th output stream and map
the channels
-map 0:3
-map 0:4
-map_channel 0.3.0:0.3
-map_channel 0.3.1:0.3
-map_channel 0.4.0:0.4
-map_channel 0.4.1:0.4
... but correct me if I'm wrong.
Soo, it's a bit complicated.
Here comes the idea. Why not amerge all the input channels and the use
mapping from the labeled "virtual stream":
-filter_complex "[0:1] [0:2] [0:3] [0:4] amerge=inputs=8 [mylabel]"
Now I have 8 channels in the "mylabel" stream, so map it to the 4 output
streams:
-map [mylabel]:0.1
-map [mylabel]:0.2
-map [mylabel]:0.3
-map [mylabel]:0.4
So far so good, but now I ended up with 4 8-channel-streams.
So I would like to use map_channel, somehow like this:
-map_channel [mylabel].0.0:0.1
-map_channel [mylabel].0.1:0.1
-map_channel [mylabel].1.0:0.2
-map_channel [mylabel].1.1:0.2
-map_channel [mylabel].2.0:0.3
-map_channel [mylabel].2.1:0.3
-map_channel [mylabel].3.0:0.3
-map_channel [mylabel].3.1:0.3
... but there is no such thing :( I can not use map_channel with amerge
labeled "virtual streams".
What is the best practice for this?
Any suggestions welcome :)
Thank You!
Zoltan
More information about the ffmpeg-user
mailing list