How can I concatenate or merge 2 or more MP4 files, in a final output MP4 file also?
I have tried in the DOS window to use the COPY command (I have read it somewhere) but it doesn't function well.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
You can try doing this with ffmpeg:
mkfifo temp0 temp1 ffmpeg -i input0.mp4 -c copy -bsf h264_mp4toannexb -f mpegts -y temp0 2> /dev/null & \ ffmpeg -i input1.mp4 -c copy -bsf h264_mp4toannexb -f mpegts -y temp1 2> /dev/null & \ ffmpeg -f mpegts -i "concat:temp0|temp1" -c copy -absf aac_adtstoasc output.mp4
This doesn't re-encode anything, it places them in a new transport stream container, which makes them more easy to concatenate, and then concatenates them back into an MP4. If output.mp4 already exists, the command will fail. The version above uses named pipes, it you're on a system that doesn't support those you'd have to use intermediate files:
ffmpeg -i input0.mp4 -c copy -bsf h264_mp4toannexb temp0.ts ffmpeg -i input1.mp4 -c copy -bsf h264_mp4toannexb temp1.ts ffmpeg -i "concat:temp0.ts|temp1.ts" -c copy -absf aac_adtstoasc output.mp4
Update: Just checked avidemux as I had it installed, after reading that other answer. It’s what you are looking for (didn’t think it can do MP4 because of its name…).
I think VirtualDubMod is mp4-capable, I didn’t use it though so I dunno for sure.
You may want to check out MeGUI. It’s a rather complex and feature-rich app and tools.
The tool for embedding in a container (mp4 in your case) is called muxer, that one can probably not concatenate them though.
You can use it in combination with VirtualDub. Virtualdub to concatenate the video streams, and the muxer to make it an mp4 again (without having to reencode).
I'm doing it with mencoder, after having converted them to avi with ffmpeg
here's a simple script, assuming you have 15 files, named 01.mp4 ... 15.mp4
#!/bin/bash for j in `seq -w 1 15`; do echo converting file $j.avi ffmpeg -i $j.mp4 $j.avi echo adding file $j.avi to list z="$z $j.avi" done echo doing append mencoder -oac copy -ovc copy $z -o all.avi