Merge mp4 Files in Linux

Merge mp4 Files in Linux

One of the best ways to prevent losing quality from concatenating files is to transcode them to mpeg transport streams, using  H.264 video and AAC audio -

$ ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts new1.ts

$ ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts new2.ts

then

$ ffmpeg -i "concat:new1.ts|new2.ts" -c copy -bsf:a aac_adtstoasc output.mp4


Notes:
- In this example I use only 2 mp4 files converted to streams and then concatenating them, but you can
put as much as you like that your system can handle

0 comments:

Post a Comment