How to concatenate multiple MP4 videos with FFMPEG without audio sync issues?

Viewed 7300

I have been trying to concatenate a number of MP4 clips (h264,aac) using the FFMPEG concat protocol documented here. The clips concatenate successfully, however there are multiple errors in the logs including:

  • Non-monotonous DTS in output stream
  • Past duration too large

Additionally, it seems that the audio and video go slightly out of sync as more clips are added - though it is more noticeable on certain players (Quicktime & Chrome HTML5).

Here is the code I am using, any tips would be appreciated!

Convert each video to temp file

ffmpeg -y -i <input file> -vcodec libx264 -acodec aac -f mpegts -bsf:v h264_mp4toannexb -mpegts_copyts 1 <temp file>

Concat temp files

ffmpeg -i concat <input1|input2 ...> -map 0 -vcodec copy -aprofile aac_low -acodec aac -strict experimental -cutoff 15000 -vbsf aac_adtstoasc -b:a 32k <output file>

1 Answers
Related