Skip to main content

Notice

Please be aware that much of the software linked to or mentioned on this forum is niche and therefore infrequently downloaded. Lots of anti-virus scanners and so-called malware detectors like to flag infrequently downloaded software as bad until it is either downloaded enough times, or its developer actually bothers with getting each individual release allow listed by every single AV vendor. You can do many people a great favor when encountering such a "problem" example by submitting them to your AV vendor for examination. For almost everything on this forum, it is a false positive.
Topic: Most efficient ways to mux a bunch of video & audio together? (FFmpeg code help) (Read 808 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Most efficient ways to mux a bunch of video & audio together? (FFmpeg code help)

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.

Re: Most efficient ways to mux a bunch of video & audio together? (FFmpeg code help)

Reply #1
LosslessCut should be able to do that with a GUI ;)

I can easily handle multiple streams and remux them. Awesome program and free!

 

Re: Most efficient ways to mux a bunch of video & audio together? (FFmpeg code help)

Reply #2
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

Re: Most efficient ways to mux a bunch of video & audio together? (FFmpeg code help)

Reply #3
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.

 
SimplePortal 1.0.0 RC1 © 2008-2021