HydrogenAudio

Digital Audio/Video => General A/V => Topic started by: noiselab on 2020-12-20 21:54:41

Title: Most efficient ways to mux a bunch of video & audio together? (FFmpeg code help)
Post by: noiselab on 2020-12-20 21:54:41
Hi, noob here. Any help is appreciated!

I have a bunch of m4v and m4a files that I'd like batch mux together.

Currently I'm using the following logic in Window's command line:
Code: [Select]
ffmpeg -i "input-video.m4v" -i "input-audio.m4a" -c:v copy -c:a copy "output-video.mp4"
So for example, I slowly convert one video at a time, using the replace text feature in notepad++:
Code: [Select]
"C:\tools\ffmpeg-4.3.1-2020-11-19-full_build\bin\ffmpeg.exe" -i "replace-me!.m4v" -i "replace-me!.m4a" -c:v copy -c:a copy "replace-me!.mp4"

I was thinking this process could be much faster if I knew how to batch convert together everything at once, maybe like whatever the variable for any filename is (*.m4v, *.m4a?) or a batch script file, so that I don't have to specify and mux each video one by one.
Title: Re: Most efficient ways to mux a bunch of video & audio together? (FFmpeg code help)
Post by: jaybeee on 2020-12-20 23:01:38
LosslessCut (https://github.com/mifi/lossless-cut/) should be able to do that with a GUI ;)

I can easily handle multiple streams and remux them. Awesome program and free!
Title: Re: Most efficient ways to mux a bunch of video & audio together? (FFmpeg code help)
Post by: Mark7 on 2020-12-21 12:14:37
You mean a Windows batch? It should be fairly easy.

Just find an example for a FOR loop to loop through the m4v files in your directory.
And you need to know how to remove the extension, to replace m4v to m4a. The same goes for mp4 output.

Some useful examples: https://stackoverflow.com/questions/3215501/batch-remove-file-extension
Title: Re: Most efficient ways to mux a bunch of video & audio together? (FFmpeg code help)
Post by: Mark7 on 2020-12-21 13:33:19
So, something like this:
Code: [Select]
@echo off
for %%f in (*.m4v) do (
echo "C:\tools\ffmpeg-4.3.1-2020-11-19-full_build\bin\ffmpeg.exe" -i "%%~nf.m4v" -i "%%~nf.m4a" -c:v copy -c:a copy "%%~nf.mp4"
)
pause

I've added an echo so it will only show what it will do, without executing anything.
Remove the echo, if you believe it will work correctly.