I succeeded merging the files using FFmpeg's demuxing feature. For .mp4
conversion, I had to explicitly convert the audio stream to avoid this error:
Could not find tag for codec pcm_s16le in stream #1, codec not currently supported in container
This is the command combining the files to merged.mp4
:
ffmpeg -f concat -i files_to_combine.txt -vcodec copy -acodec aac -strict -2 -b:a 384k merged.mp4
If the output file can be also a .MOV
file, the command is:
ffmpeg -f concat -i files_to_combine.txt -vcodec copy -acodec copy merged.MOV
Here's the content of the text file files_to_combine.txt
:
file ./first_file.MOV
file ./second_file.MOV
If you get the error
Unsafe file name 'file with spaces.mov'
files_to_combine.txt: Operation not permitted
and trust the file names, you can add -safe 0
to get around this error. See FFmpeg's man page:
ffmpeg -safe 0 -f concat ...
Shorter commands
Trying the same task five years later, I also had success with
ffmpeg -f concat -i files_to_combine.txt merged.mov
and
ffmpeg -f concat -i files_to_combine.txt -f mp4 merged.mp4