mifi / lossless-cut

The swiss army knife of lossless video/audio editing
https://losslesscut.app/
GNU General Public License v2.0
28.09k stars 1.36k forks source link

Playback errors in merged file (Invalid video timestamp) #1202

Open cunlem opened 2 years ago

cunlem commented 2 years ago

Sometimes when cutting and merging youtube H.264 video I get a file with glitches at merge points that result in playback/seek errors in the player output (here mpv)

V: 00:00:25 / 00:00:28 (89%) Invalid video timestamp: 25.730367 -> 25.730367

This is not a bug in losslesscut but rather ffmpeg. Just writing to ask if others have experienced something similar and know why it happens

mifi commented 2 years ago

which different export settings did you try? does it give the same result regardless?

cunlem commented 2 years ago

The defaults basically. I always use keyframe cut (the other option gives weird results). I tried fiddling with avoid negative timestamp value too.

The problem seems to be related to some of H.264 encoded videos from Youtube, especially when setting cut ends not on last frame before keyframe but somewhere in the middle of GOP. The file cuts play without errors after split. But after merge glitches at join points appear. Often typical errors in console during playback look like:

[null @ 0x56409c9d9c80] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 113 >= 113
[h264 @ 0x56409ca41980] illegal short term buffer state detected
[h264 @ 0x56409ca56040] mmco: unref short failure

I haven't experienced such problems with VP9 Youtube videos. They are easier to cut in general. But H.264 is usually the highest quality version due to bigger size.

mifi commented 2 years ago

Oh, that's interesting. I guess all we could do is to gather a minimal reproducible example command line with ffmpeg and report to ffmpeg.

cunlem commented 2 years ago

I analyzed it bit further and filed a bug with ffmpeg. Hopefully it's a matter of getting timestamp math right and they will be able to fix it.