VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Member
    Join Date
    May 2024
    Location
    Manchester
    Search PM
    If I open a mxf file in audacity and save the WAV (original format) audio as a 320kbps aac file I can then encode the mxf file to a mp4 with the aac/m4a audio using the following ffmpeg command.

    ffmpeg -i "D:\input.mxf" -i "D:\audo.m4a" -c:v h264_nvenc -r 50 -cq:v 18 -aspect 16:9 -pix_fmt yuv420p -vf "bwdif=mode=1" -acodec copy "D:\output.mp4"

    but if I was to save the audio as a 640kbps .ac3 file using audacity too, how would I go about adding that as a second track to the mp4 file? I've tried just adding another input but I'm getting errors.

    I need AAC for compatibility but there's a lot of talk online about ffmpeg's aac not being good quality, so I'd like a back up track that's apparently of better quality while still being smaller than the original wav (.wav wouldn't go in a mp4 container anyway).
    Quote Quote  
  2. Here you go:
    Code:
    ffmpeg -i "D:\input.mxf" -i "D:\audio.m4a" -i "D:\audio.ac3" -map 0:v -map 1:0 -map 2:0 -c:v h264_nvenc -c:a copy -r 50 -cq:v 18 -aspect 16:9 -pix_fmt yuv420p -vf "bwdif=mode=1" "D:\output.mp4"
    Quote Quote  
  3. Member
    Join Date
    May 2024
    Location
    Manchester
    Search PM
    Thank you so much!

    I'll give that a try.

    I don't suppose there's a way I could remove audacity from my workflow completely. The mxf files I have have 16 mono channels (all empty bar the first two). I use audacity to make a stereo track using the first two mono channels and then that is what I save as aac / will also be saving as ac3.

    Is there a way to instruct ffmpeg to encode using the first two mono channels and map to stereo e.g. 1/FL 2/FR? Encoding both a AAC and a AC3 track with them.
    Quote Quote  
  4. Yes, check this:
    https://trac.ffmpeg.org/wiki/AudioChannelManipulation#a2monostereo

    Bellow example how it may look in ffmpeg - not tested as i have no similar source to yours - ffmpeg can be tricky in such things but definitely it is doable.

    Code:
    ffmpeg -i "D:\input.mxf" -filter_complex "[0:a:0][0:a:1]join=inputs=2:channel_layout=stereo,asplit=2[audio_1][audio_2];[0:v]bwdif=mode=1[video]" -map "[video]" -c:v h264_nvenc -r 50 -cq:v 18 -aspect 16:9 -pix_fmt yuv420p -map "[audio_1]" -c:a:1 libfdk_aac -b:a:1 320k -map "[audio_2]" -c:a:2 ac3 -b:a:2 640k "D:\output.mp4"
    Last edited by pandy; 13th May 2024 at 17:44.
    Quote Quote  
  5. Member
    Join Date
    May 2024
    Location
    Manchester
    Search PM
    Originally Posted by pandy View Post
    Yes, check this:
    https://trac.ffmpeg.org/wiki/AudioChannelManipulation#a2monostereo

    Bellow example how it may look in ffmpeg - not tested as i have no similar source to yours - ffmpeg can be tricky in such things but definitely it is doable.

    Code:
    ffmpeg -i "D:\input.mxf" -filter_complex "[0:a:0][0:a:1]join=inputs=2:channel_layout=stereo,asplit=2[audio_1][audio_2];[0:v]bwdif=mode=1[video]" -map "[video]" -c:v h264_nvenc -r 50 -cq:v 18 -aspect 16:9 -pix_fmt yuv420p -map "[audio_1]" -c:a:1 libfdk_aac -b:a:1 320k -map "[audio_2]" -c:a:2 ac3 -b:a:2 640k "D:\output.mp4"
    Thanks Pandy. I'll give that a try asap. Will have to change from libfdk to the standard aac encoder as my ffmpeg is not compiled with libfdk. That's one of the reasons I have to have the ac3 track as back-up as apparently the standard aac encoder in ffmpeg isn't that good (How much credence would you give these claims? There's conflicting advice online with some saying it's got better and others advising against its use and to use libfdk instead). Compiling ffmpeg sounds a bit too complicated for me so I just use the standard installation.
    Quote Quote  
  6. Originally Posted by DebbieGl View Post
    Thanks Pandy. I'll give that a try asap. Will have to change from libfdk to the standard aac encoder as my ffmpeg is not compiled with libfdk. That's one of the reasons I have to have the ac3 track as back-up as apparently the standard aac encoder in ffmpeg isn't that good (How much credence would you give these claims? There's conflicting advice online with some saying it's got better and others advising against its use and to use libfdk instead). Compiling ffmpeg sounds a bit too complicated for me so I just use the standard installation.
    Well... just use nonfree ffmpeg version with libfdk compiled in ( search for "Automated nonfree builds of FFmpeg for Windows" ). AC3 is definitely way more popular and widely supported by almost all consumer decoders. I have impression that with 320kbps even generic ffmpeg aac encoder should be OK.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!