-
Notifications
You must be signed in to change notification settings - Fork 35
Fallback to DTS if PTS info doesn't exist #683
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
Conversation
# Should never happen, but prevents ZeroDivisionError: | ||
or self.end_stream_seconds_from_content | ||
== self.begin_stream_seconds_from_content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't actually needed anymore, i.e. the dts fallback already fixed the metadata issue. But it's probably safer to have this regardless?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, let's keep it. I think a single frame video is allowed, and we would encounter this problem with such a video.
# https://huggingface.co/datasets/raushan-testing-hf/videos-test/blob/main/sample_video_2.avi | ||
# We can't check it into the repo due to potential licensing issues, so | ||
# we have to unconditionally skip this test.# | ||
# TODO: encode a video with no pts values to unskip this test. Couldn't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another great catch!
Some videos, like https://huggingface.co/datasets/raushan-testing-hf/videos-test/blob/main/sample_video_2.avi mentioned in #673, do not have any PTS value for their packets.
Up until now, this caused various weird issues like #677 and #676, and some silently-wrong error (e.g. index-based API with exact mode were always returning the first frame).
This PR allows for proper decoding of such poorly-encoded videos, by falling back to the DTS info if the PTS do not exist.
I added a test, which is skipped unconditionally. We should enable it back once we can check in such a poorly-encoded video. I made sure the test properly pass on https://huggingface.co/datasets/raushan-testing-hf/videos-test/blob/main/sample_video_2.avi with FFmpeg 4 and 6.
(needs #682 first. Note that the
sample_video_2.avi
video is one of those videos were timebase.den != 1, which exposed the bug that is fixed in #682).