[FFmpeg-user] Matroska segmented output changes video duration

andreymal me at andreymal.org
Wed Jan 29 23:46:53 EET 2020


Hello. I have a video grabbed from EasyCAP (UTV007). It has variable
frame rate, so I use "-vsync passthrough" everywhere to keep it. You can
download a segment of this video here:
https://andreymal.org/files/ffmpeg/contra_test.mkv

I need to split this video into several segments. I tried to use this
command:

ffmpeg -vsync passthrough -i contra_test.mkv \
  -map 0 -c copy -f segment -segment_time 1 \
  -segment_list test.ffcat -reset_timestamps 1 test-%02d.mkv

To verify that everything is fine, I merge the video back:

ffmpeg -vsync passthrough -i test.ffcat \
  -map 0 -c copy contra_test_union.mkv

Then I compare the durations, and the new video (and the audio) is 2
seconds longer!

$ ffmpeg -i contra_test.mkv 2>&1 | grep DURATION
      DURATION        : 00:00:30.007000000
      DURATION        : 00:00:30.069000000
$ ffmpeg -i contra_test_union.mkv 2>&1 | grep DURATION
      DURATION        : 00:00:32.156000000
      DURATION        : 00:00:32.188000000

The more segments the video is splitted into, the longer the new video.

Could someone explain what caused this behavior? Is it possible to fix
it? I expect the same durations.

But when I use mp4 instead of mkv, everything works well. Is this a
matroska bug?

I use ffmpeg 4.2.2 installed from Arch Linux repository.
________
andreymal


More information about the ffmpeg-user mailing list