There are two methods within ffmpeg that can be used to concatenate files of the same type: the concat ”demuxer” and the concat ”protocol”. The demuxer is more flexible – it requires the same codecs, but different container formats can be used; and it can be used with any container formats, while the protocol only works with a select few containers. However, the concat protocol is available in older versions of ffmpeg, where the demuxer isn’t.
via Concatenate – FFmpeg.
I needed a way to concatenate mp4 files generated from all the IP cameras connected to the open wifi. I tried compiling MP4Joiner but there were way too many dodgy dependencies throwing code errors in the compile. Then I read that simple ffmpeg, a package easily loaded onto a Linux box, can merge mp4 files and it works. Unfortunately concat only works on later Fedora releases like Fedora 19 and above but it’s easier than manually merging them in Avidemux. My main server still runs Fedora 14 for many reasons so merging them simply requires running a command manually in a Fedora 19 or above Virtual Machine. In the future when I migrate to a later release this can all be scripted seamlessly.
Here’s more as to how it’s done in ffmpeg…
Create a file mylist.txt with all the files you want to have concatenated in the following form (lines starting with a # are ignored):# this is a comment file '/path/to/file1' file '/path/to/file2' file '/path/to/file3'
Note that these can be either relative or absolute paths. Then you can stream copy or re-encode your files:ffmpeg -f concat -i mylist.txt -c copy output