[FFmpeg-user] more sound madness, looks SOLVED

Bouke / VideoToolShed bouke at videotoolshed.com
Tue Mar 10 13:12:10 EET 2020



> On 10 Mar 2020, at 07:28, Ted Park <kumowoon1025 at gmail.com> wrote:
> 
>> ? Start is the same, but then I’m lost...
>> 
>>> channelmap=map=0-0|1-1|2-2:
>> This also confuses me. The order of the second and third mapping looks likes it comes from the 0 1 1 yadda at the beginning.
>> But where is channel 0 from the second input mapped? Whatever I try, I always end up with channel 0...
> 
> The channels aren’t on every single bit field, but that’s basically it, I just wanted to try to minimize the variables to see if I could get the same thing to work, because arguments and filter parameters related to audio channels seem to vary (or maybe it’s a discrepancy in the docs)  From libavutil/channel_layout.h:
> #define AV_CH_FRONT_LEFT             0x00000001
> #define AV_CH_FRONT_RIGHT            0x00000002
> #define AV_CH_FRONT_CENTER           0x00000004
> #define AV_CH_LOW_FREQUENCY          0x00000008
> #define AV_CH_BACK_LEFT              0x00000010
> #define AV_CH_BACK_RIGHT             0x00000020
> #define AV_CH_FRONT_LEFT_OF_CENTER   0x00000040
> #define AV_CH_FRONT_RIGHT_OF_CENTER  0x00000080
> #define AV_CH_BACK_CENTER            0x00000100
> #define AV_CH_SIDE_LEFT              0x00000200
> #define AV_CH_SIDE_RIGHT             0x00000400
> #define AV_CH_TOP_CENTER             0x00000800
> #define AV_CH_TOP_FRONT_LEFT         0x00001000
> #define AV_CH_TOP_FRONT_CENTER       0x00002000
> #define AV_CH_TOP_FRONT_RIGHT        0x00004000
> #define AV_CH_TOP_BACK_LEFT          0x00008000
> #define AV_CH_TOP_BACK_CENTER        0x00010000
> #define AV_CH_TOP_BACK_RIGHT         0x00020000
> #define AV_CH_STEREO_LEFT            0x20000000  ///< Stereo downmix.
> #define AV_CH_STEREO_RIGHT           0x40000000  ///< See AV_CH_STEREO_LEFT.
> #define AV_CH_WIDE_LEFT              0x0000000080000000ULL
> #define AV_CH_WIDE_RIGHT             0x0000000100000000ULL
> #define AV_CH_SURROUND_DIRECT_LEFT   0x0000000200000000ULL
> #define AV_CH_SURROUND_DIRECT_RIGHT  0x0000000400000000ULL
> #define AV_CH_LOW_FREQUENCY_2        0x0000000800000000ULL
> I figured the hex notation was a way to leave little to be interpreted/resolved but apparently that wasn’t the issue. I used the channels labeled stereo mix and top back right thinking they were less likely to overlap, so 0x60020000 stands for 0x40000000|0x20000000|0x00020000.

Hi Ted,
> What is the error you get with channel map? Or does it just set the channels to be silent or disable them with no warning again?

Forget it, I think (with your help) I’ve nailed it.

> The multitrack file is actually labeled as the down mix on the first two channels, then the recorded tracks:
>> Input #1, wav, from '/Volumes/Data/test/068.WAV':
>> Metadata:
>>   comment         : sSPEED=025.000-ND 
>>                   : sTAKE=068 
>>                   : sUBITS=$00000000 
>>                   : sSWVER=5.01.8149 
>>                   : sSCENE=MixPre 
>>                   : sFILENAME=MixPre-068.WAV 
>>                   : sTAPE=200130 
>>                   : sCIRCLED=FALSE 
>>                   : sTRK1=MixL 
>>                   : sTRK2=MixR 
>>                   : sTRK3=Track 1 
>>                   : sTRK4=Track 2 
>>                   : sTRK5=Track 3 
>>                   : sTRK6=Track 4 
>>                   : sTRK7=Track 5 
>>                   : sTRK8=Track 6 
>>                   : sTRK9
>>   encoded_by      : SoundDev: MixPre-10 II TJ0019225
>>   originator_reference: USSDVTJ001922501520013072A000201
>>   date            : 2020-01-30
>>   creation_time   : 07:02:20
>>   time_reference  : 2468718515
>>   coding_history  : A=PCM,F=48000,W=24,M=multi,R=48000,T=10 Ch;Ambisonics=off 

I don’t think this metadata is used. (And it’s incomplete as well, this is just a dump of the BEXT chunk that is not large enough to store all the metadata there is.
So, the names are completely irrelevant for FFmpeg. (And for everyone, as the good stuff is in the iXML.)
I must admit, have not tested it very well, but I would expect that there is a -ignore_metadata command as input option if it turns out I’m wrong here.

> Maybe you will get automatic channel detection working again if you don’t include the stereo and use the 8 channels.

Not  an option, as what I’m making is intended to merge cam sound with external sound


> Are some of the tracks actually sub-mixes bounced on the device? (Since you get tracks 8 and 9)

Probably, but that’s beside the issue, it’s not up to me what end users want to map to where :-)

What DOES work as expected:
(Reverse mapping of BWF sound, with the last channel duplicated, reverse mapping of the two video sound channels.)
The channelmap from the BWF is a sum of (zero based) 2 to 12 from you list above, to leave room for the 0x3 (first two) for the video sound:

/Applications/ffmpeg -i /Volumes/Data/test/10track.wav -i /Volumes/Data/test/input.mp4 -filter_complex "[0:a]channelmap=9-0|8-1|7-2|6-3|5-4|4-5|3-6|2-7|1-8|0-9|9-10:channel_layout=0x8FFC,[1:a]join=inputs=2:channel_layout=0x1FFF,channelmap=map=0-0|1-1|2-2|3-3|4-4|5-5|6-6|7-7|8-8|9-9|10-10|11-11|12-12:channel_layout=0x1FFF[out]" -map "[out]" -c:a pcm_s24le -map 1:1 -c:v copy  /Volumes/Data/test/ted59.mov

To make it easier, amerge, works as expected:

 /Applications/ffmpeg -i /Volumes/Data/test/10track.wav -i /Volumes/Data/test/input.mp4 -filter_complex "[0:a]channelmap=9-0|8-1|7-2|6-3|5-4|4-5|3-6|2-7|1-8|0-9|9-10:channel_layout=0x8FFC[a0];[1:a]channelmap=1-0|0-1:channel_layout=0xC[a1];[a1][a0]amerge=inputs=2[out]" -map "[out]" -c:a pcm_s24le -map 1:1 -c:v copy  /Volumes/Data/test/ted61.mov

Even easier: (Since the filter_complex now isn’t feeding the next, and proof that the channelmap is just a dummy:

 /Applications/ffmpeg -i /Volumes/Data/test/10track.wav -i /Volumes/Data/test/input.mp4 -filter_complex "[0:a]channelmap=9-0|8-1|7-2|6-3|5-4|4-5|3-6|2-7|1-8|0-9|9-10:channel_layout=0x7FF[a0];[1:a]channelmap=1-0|0-1:channel_layout=0x3[a1];[a1][a0]amerge=inputs=2[out]" -map "[out]" -c:a pcm_s24le -map 1:1 -c:v copy  /Volumes/Data/test/ted62.mov

This makes it easy to break the whole shebang down so an end user can map any combo in any order without me having to jump hoops :-)

Thanks for your help!

Bouke

> Regards,
> Ted Park
> 
> _____________________________________



More information about the ffmpeg-user mailing list