Mix all channels down to one stereo track

Questions and answers on how to get the most out of FFAStrans
graham728
Posts: 76
Joined: Sat Oct 13, 2018 10:54 pm

Mix all channels down to one stereo track

Post 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
momocampo
Posts: 593
Joined: Thu Jun 08, 2017 12:36 pm
Location: France-Paris

Re: Mix all channels down to one stereo track

Post 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.
graham728
Posts: 76
Joined: Sat Oct 13, 2018 10:54 pm

Re: Mix all channels down to one stereo track

Post by graham728 »

Great! I'll give this a try. Thank you very much!
graham728
Posts: 76
Joined: Sat Oct 13, 2018 10:54 pm

Re: Mix all channels down to one stereo track

Post 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.
momocampo
Posts: 593
Joined: Thu Jun 08, 2017 12:36 pm
Location: France-Paris

Re: Mix all channels down to one stereo track

Post by momocampo »

Good to hear ;)
And of course it works :D I have been using it for a while.
Cheers.
User avatar
FranceBB
Posts: 237
Joined: Sat Jun 25, 2016 3:43 pm
Contact:

Re: Mix all channels down to one stereo track

Post 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. :)
Railio
Posts: 14
Joined: Wed May 31, 2023 7:23 am

Re: Mix all channels down to one stereo track

Post 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!
Attachments
WIP_AUDIOMIX.json
(7.13 KiB) Downloaded 132 times
emcodem
Posts: 1672
Joined: Wed Sep 19, 2018 8:11 am

Re: Mix all channels down to one stereo track

Post 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
emcodem, wrapping since 2009 you got the rhyme?
Railio
Posts: 14
Joined: Wed May 31, 2023 7:23 am

Re: Mix all channels down to one stereo track

Post 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!
Attachments
WIP_AUDIOMIX.json
(8.89 KiB) Downloaded 146 times
emcodem
Posts: 1672
Joined: Wed Sep 19, 2018 8:11 am

Re: Mix all channels down to one stereo track

Post 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
emcodem, wrapping since 2009 you got the rhyme?
Post Reply