Page 1 of 2

Mix all channels down to one stereo track

Posted: Tue Jan 19, 2021 1:12 pm
by graham728
Hi,

I'm wondering if there is a way to take an MXF file that has audio stems attached (possibly 16 channels) and mix all these tracks down to one stereo track and then re-export as an MXF again.

So all audio stems are mixed down into one stereo track. I've tried using the channel mapper with no success...

Any help would be great.

Thanks

Re: Mix all channels down to one stereo track

Posted: Tue Jan 19, 2021 3:09 pm
by momocampo
Hello Graham,
Hehehe that's exactly that I was looking for not long ago, lucky man.
Fortunatly for me, and now for you, our dear Francebb gave me the trick. You have to use a A/V Media decoder+custom avisynth node.
here is what you have to put into the custom avisynth node :

Code: Select all

# Variables:
#
# m_clip		= The last returned AviSynth media
#
# Do NOT change any of the following variables!!!
# _ffas_video 	= <original video>
# _ffas_audio	= <original audio>
# _ffas_height	= <source height>
# _ffas_width	= <source width>
# _m_clip_a_channels = <total channels>
# _ffas_work_fdr	= Working folder for the workflow
#
Odd=GetChannel(m_clip, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31).ConvertToMono()
Even=GetChannel(m_clip, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32).ConvertToMono()
stereo=MergeChannels(Odd, Even)
m_clip=AmplifyDb(stereo, 25)

# The following MUST be the last line of your script
Return m_clip
It's for 32 channel but it will work for 16
Beware, I set the "amplifyDb to 25, maybe you should set it lower if your audio is too loud.

Just put an encoder node after and voilĂ  ;)
Hope it helps.
B.

Re: Mix all channels down to one stereo track

Posted: Tue Jan 19, 2021 5:20 pm
by graham728
Great! I'll give this a try. Thank you very much!

Re: Mix all channels down to one stereo track

Posted: Tue Jan 19, 2021 9:10 pm
by graham728
Update: For any future view - I can confirm this works. I've set the DB down to around 18.

AV Decoder > Custom AV Script Node (Copy above script) > Transcoder (I used ProRes) 1 Discrete Track 2 Channels.

Output was a fully mixed down audio ProRes. I did a test where the audio was only on tracks 8+9 - outputted ProRes has mixed audio on Tracks 1+2.

Hope this helps anyone else.

Re: Mix all channels down to one stereo track

Posted: Tue Jan 19, 2021 11:41 pm
by momocampo
Good to hear ;)
And of course it works :D I have been using it for a while.
Cheers.

Re: Mix all channels down to one stereo track

Posted: Wed Jan 20, 2021 11:05 am
by FranceBB
I'm glad you're finding it useful.
I didn't know there were other people interested in this, but if there are, maybe I can think about integrating it in the Channel Mapper or maybe create a node for it, I have to ask GrandMaster.
As to the fact that there are 32 channels, it's because the A/V Decoder always creates 32 channels from the source, so I was just playing safe. :)
As to AmplifyDB, it really should be used according to your needs. There's also Normalize(0.22) in Avisynth to get everything to -24 LUFS, the problem is that it will bring the audio down if it's higher, but it won't raise it up if it's lower. In FFMpeg, however, there's loudnorm that does just that (it raises and lowers the audio accordingly to perform e true loudness correction): -af loudnorm=I=-24:LRA=14:tp=-2
The reason why I didn't suggest it when I was talking with momo a while ago was that his files were only going to be used for reference, so having them perfectly matching -24 LUFS wasn't really needed, however if you're planning to deliver them somewhere to end users, you should really do that.

Cheers,
Frank. :)

Re: Mix all channels down to one stereo track

Posted: Wed May 31, 2023 7:43 am
by Railio
hello!
I am joining this conversation as this is EXACTLY what I need :)
First of all thanks for the amazing piece of software that FFastrans is,
and second of all, I am a completely newbie to it.

We have MP4 files with a stereo track, on Ch1 we have voiceover and on Ch2 atmos.
We keep the channels for archiving reasons, but we need a downmix for transmission.
I have been trying the above solution but I don't seem to be able to make it work.
I get a successful result from the process but the resulting stereo track is as the original file.
Would you be able to point me towards what I am doing wrong?

We used to work on macs and on FFWorks we would add an "audio merge" audio filter and got the result we needed.

Many thanks!

Re: Mix all channels down to one stereo track

Posted: Wed May 31, 2023 11:39 am
by emcodem
Hey @Railio,
welcome to the club :D

So what above avisynth custom script does is to collect all input odd channels to output stereo left and input even channels to output stereo right.

Code: Select all

Odd=GetChannel(m_clip, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31).ConvertToMono()
Even=GetChannel(m_clip, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32).ConvertToMono()
stereo=MergeChannels(Odd, Even)
As far as i understand you want something different, e.g. you want to merge input stereo left + right to output mono ch 1 (xdcam has only mono tracks).

So i believe in your custom avisynth processor, you should have something like this:

Code: Select all

mono=GetChannel(m_clip, 1, 2).ConvertToMono()
m_clip=AmplifyDb(stereo, 25)
Return m_clip

Re: Mix all channels down to one stereo track

Posted: Wed May 31, 2023 2:08 pm
by Railio
Thank you! Yes, correct, what I need is the two channels mixed together.

I tried your solution but I get the error:
Validate: I don't know what 'stereo' means.
I also tried bypassing the line m_clip=AmplifyDb(stereo, 25) but still, the channels are not mixed.

Could you have a look at the attached workflow and see what/where I am doing wrong?
Thanks again!

Re: Mix all channels down to one stereo track

Posted: Wed May 31, 2023 3:28 pm
by emcodem
@Railio
Sure, my fault. try this:

Code: Select all

mono=GetChannel(m_clip, 1, 2).ConvertToMono()
m_clip=AmplifyDb(mono, 25)
Return m_clip