I'm trying to batch remux files to mp4, copying audio, video and subtitles streams.

ffmpeg -i "$file" -map 0:a:m:language:por\? -map 0:a:m:language:eng\? -map 0:s:m:language:por\? -map 0:s:m:language:eng\? -map 0:v -c:v copy -c:s mov_text -c:a copy -movflags faststart -f mp4 "${file%.*}"-remux.mp4

But I get lots of errors sometimes about timestamps and non-monotous DTS streams.

Searching online I found those 2 flags here:

-fflags "+genpts" -avoid_negative_ts "make_zero"

But they don't fix my issue. What is the best way to fix this issues and make sure audio, subtitles and video are still in sync? Looking for something safe to apply to any input file in batch processing scripts, without re-encoding

  • Nothing to do about those. Those messages indicate faulty timestamps in the input so ffmpeg does its best to correct them. – Gyan May 21 '20 at 6:53
  • Is it safe to use the 2 flags I found? What about +igndts ? – Freedo May 21 '20 at 7:53
  • No, genpts will generate new timestamps which will destroy original timings. avoid_negative_ts will just add a uniform offset, and not change monotonicity. igndts will also regenerate timestamps. As long as the video plays fine, I'd just ignore it. – Gyan May 21 '20 at 8:42
  • But do you recommend using those options if I'm going to batch process thousands of files? I don't care about regenerating stuff as long it doesn't cause issues / improve stuff – Freedo May 21 '20 at 9:31
  • It will cause issues if input is variable frame rate. – Gyan May 21 '20 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.