ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Append audio to video - command line

(1/1)

Masonjar13:
I'm looking for a way to append a single mp3 with a single mp4. I have several hundred video/audio pairs that need this done. I'm not doing them each by hand, which is why I specifically need a command-line software. I tried with Avidemux:
Code in AHK
--- Code: Autohotkey ---Loop, *.mp3{    StringReplace,vname,A_LoopFileName,mp3,mp4    RunWait, %Comspec% /c avidemux --load %vname% --external-mp3 %A_loopFileName% --audio-map --save /done/%A_LoopFileName% --output-format MP4 --quit}
But all that does is open the program in a window. Same response when ran directly from the cmd prompt. Are there any other programs out there that can do this? Or is there just something wrong with my commands?

Nod5:
Try this ffmpeg method:

--- ---ffmpeg -i video.mp4 -i audio.mp3 -map 0:v -map 1:a -codec copy -shortest out.mp4
Edit: Afterwards realized you wrote "append". If you by that meant "add an audio track to play in parallel with the video" then the ffmpeg code should work. But not if you meant concatenation (first video, then afterwards some audio).

Masonjar13:
My mistake on the wording. Yes, I did mean to have them parallel. I'll try it out when I can and post back, thanks!

4wd:
You want to multiplex them, ie. mux them together.

Using nod5's ffmpeg command line above, this command file will do every pair in a directory:


--- Code: Text ---@echo offrem MuxIt.cmd <folder>remrem Put ffmpeg.exe in your PATH or edit to include full path to itpushd "%~1"for %%a in ("*.mp4") do (  ffmpeg.exe -i "%%~a" -i "%%~na.mp3" -map 0:v -map 1:a -codec copy -shortest "%%~na-mux.mp4")popd
eg.

"te st.mp4" and "te st.mp3" will become "te st-mux.mp4"

EDIT: BTW, your original AHK script probably would have worked if you'd used the AVIDemux CLI binary, (avidemux2_cli.exe) - not sure, I've always used its GUI version.

Navigation

[0] Message Index

Go to full version