-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use PTS differences for _Duration props #89
Conversation
Test this with a shitty m2ts stream where the PTS is unavailable for many frames. Not a bad idea but I'm not sure it's all the way there in realiability. |
H.222 says that, if a PTS is not specified, it is is the responsibility of the decoder to interpolate the missing timestamps. I.e If libavcodec marks unspecified PTS appropriately (UINT_MAX iirc?), then you can use the estimated frame duration. Arguably it is FFmpeg job to do it. For audio streams in TS container, it is somewhat common. |
FFmpeg doesn't do it. Without code to take unknown PTS into account you'll get very weird values out of this one sometimes. |
libavformat mpegts.c always resets the PTS to FWIW this PR may also lead to incorrect |
Does VS allow leaving Also, do you know where I can find samples for m2ts streams with missing PTSs for many frames? I have a few files that are missing timestamps for one or two frames, but not for more. |
I don't have such samples. H.222 states that a decoder must be able to interpolate timestamps for as long as 700 ms. Broadcasters are generally well behaved and avoid it or stick to small gaps. If _Duration is merely informative, I would just set it to some undefined value and call it a day. A proper fix must consider neighbouring PTSs. You wouldn't want to interpolate a PTS ahead of the next frame, which sets the values properly. |
Just leave |
I have a few of these M2TS downloaded from a Digital8 camera. Since they are private, I can only provide a link to one of them via email. MAGIX Vegas reads them correctly, ffmpeg recodes them correctly, MPC plays them correctly -- but none of the AviSynth plugins can read them correctly without desync the video from the audio. |
546ea79
to
6e90a1f
Compare
Took a while, but I updated this now. As discussed it just leaves |
0068de0
to
f22e144
Compare
frame->duration is often just computed from the track-wide frame rate and hence unreliable. When the duration cannot be reliably computed from PTS values (like on the last frame or when frames have NOPTS), leave _Duration unset. That way, the caller can decide whether or how to guess values if necessary.
Shut up the CI failure
frame->duration is often just computed from the track-wide frame rate and hence unreliable.
For the last frame, where no following PTS is available, the logic just matches the previous frames's duration. In theory the track's duration could be referenced instead, but the current logic matches FFMS2.