Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Most efficient ways to mux a bunch of video & audio together? (FFmpeg code help) (Read 2550 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.