-
Notifications
You must be signed in to change notification settings - Fork 64
Description
Some videos, like these ones
Lines 752 to 756 in 9fa4fd1
def supports_approximate_mode(asset: TestVideo) -> bool: | |
# TODONVDEC P2: open an issue about his. That's actually not related to | |
# NVDEC at all, those don't support approximate mode because they don't set | |
# a duration. CPU decoder fails too! | |
return asset not in (AV1_VIDEO, TEST_SRC_2_720P_VP9, TEST_SRC_2_720P_VP8) |
simply do not work with approximate mode. They're all missing the duration_from_header
metadata because avStream->duration
is invalid here:
torchcodec/src/torchcodec/_core/SingleStreamDecoder.cpp
Lines 121 to 124 in 9fa4fd1
if (avStream->duration > 0 && avStream->time_base.den > 0) { | |
streamMetadata.durationSecondsFromHeader = | |
ptsToSeconds(avStream->duration, avStream->time_base); | |
} |
and they end up failing with:
torchcodec/src/torchcodec/decoders/_video_decoder.py
Lines 420 to 424 in 9fa4fd1
if metadata.end_stream_seconds is None: | |
raise ValueError( | |
"The maximum pts value in seconds is unknown. " | |
+ ERROR_REPORTING_INSTRUCTIONS | |
) |
which isn't a particularly helpful error message, especially since ERROR_REPORTING_INSTRUCTIONS
says:
torchcodec/src/torchcodec/decoders/_decoder_utils.py
Lines 15 to 18 in 9fa4fd1
ERROR_REPORTING_INSTRUCTIONS = """ | |
This should never happen. Please report an issue following the steps in | |
https://github.com/pytorch/torchcodec/issues/new?assignees=&labels=&projects=&template=bug-report.yml. | |
""" |
We should, at the very least, provide a more sensible error message. But we should also probably try to figure what we can do with those videos to support approximate mode. ffprobe
is able to report the duration of those videos: we should try to see if they're able to report it without scanning.
And if really, we conclude that they can't support approximate mode, we should probably automatically fallback to exact mode (CC @scotts as this was your idea!)