Since you are not transcoding, you cannot merge two mp4 containers in exactly the same way. See this page .
Essentially, you need to convert the files (without transcoding) to MPEG transport streams:
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
You will need the latest version ffmpeg. Try sudo apt-get update; sudo apt-get install ffmpeg(on Ubuntu Linux) or brew update; brew install ffmpeg(on Mac OS X)
source
share