0

I've encountered an issue while concatenating video files using FFmpeg, specifically when including multiple streams using the -map 0 option. Here are the details:

I have two FFmpeg commands to trim the first three seconds of a video from a public sample:

  1. Without -map 0:

    ffmpeg -i http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -t 3 output_t.mp4 -y
    
  2. With -map 0:

    ffmpeg -y -i http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -map 0 -t 3 output_t.mp4
    

When using the output from the first command in a concat demuxer, everything works fine. However, using the output from the second command results in numerous "Non-monotonic DTS in output stream" errors and the final video's length is incorrect.

The whole process looks like

ffmpeg -y -i http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -map 0 -t 3 output_t.mp4
ffmpeg -y -i http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -filter_complex '[0]trim=duration=3[s0];[0]atrim=duration=3[s1]' -map '[s0]' -map '[s1]' trim_atrim_duration.mp4
ffmpeg -y -f concat -safe 0 -i files.txt -map 0 -c copy concat_demuxer.mp4

the body of files

file 'output_t.mp4'
file 'trim_atrim_duration.mp4'

Here are my questions:

Why does including -map 0 (to include all streams) in the trimming process cause non-monotonic DTS errors when those segments are later used in a concat demuxer?

Any advice on how to diagnose and resolve these issues would be greatly appreciated. I'm particularly interested in understanding the underlying cause of the non-monotonic DTS errors and finding a reliable workflow for trimming and concatenating videos with multiple streams.

Thank you for your help!

I tried analysis the PTS & DTS to see if there is any difference between the w/o map output_t.mp4


ffprobe -v error -select_streams v -show_entries frame=pkt_pts_time,pkt_dts_time -of default=noprint_wrappers=1:nokey=1 output_t.mp4 > video_pts_dts.txt
ffprobe -v error -select_streams a -show_entries frame=pkt_pts_time,pkt_dts_time -of default=noprint_wrappers=1:nokey=1 output_t.mp4 > audio_pts_dts.txt

but didn't find any difference

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.