Skip to content

ZeroDivisionError when accessing metadata #676

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

Open
NicolasHug opened this issue May 12, 2025 · 0 comments
Open

ZeroDivisionError when accessing metadata #676

NicolasHug opened this issue May 12, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@NicolasHug
Copy link
Member

NicolasHug commented May 12, 2025

Using https://huggingface.co/datasets/raushan-testing-hf/videos-test/blob/main/sample_video_2.avi. See also #677 for decoding problems with this video.

approximate mode is OK, but exact mode fails in the average_fps property.

decoder = VideoDecoder(path, seek_mode="approximate")
decoder.metadata

VideoStreamMetadata:
  duration_seconds_from_header: 9.02507
  begin_stream_seconds_from_header: 0.0
  bit_rate: 333644.0
  codec: h264
  stream_index: 0
  begin_stream_seconds_from_content: None
  end_stream_seconds_from_content: None
  width: 320
  height: 240
  num_frames_from_header: 270
  num_frames_from_content: None
  average_fps_from_header: 29.916667
  duration_seconds: 9.02507
  begin_stream_seconds: 0
  end_stream_seconds: 9.02507
  num_frames: 270
  average_fps: 29.916667
decoder = VideoDecoder(path, seek_mode="exact")
decoder.metadata

File ~/dev/torchcodec/src/torchcodec/_core/_metadata.py:147, in VideoStreamMetadata.average_fps(self)
    141 if (
    142     self.end_stream_seconds_from_content is None
    143     or self.begin_stream_seconds_from_content is None
    144     or self.num_frames is None
    145 ):
    146     return self.average_fps_from_header
--> 147 return self.num_frames / (
    148     self.end_stream_seconds_from_content
    149     - self.begin_stream_seconds_from_content
    150 )


@NicolasHug NicolasHug added the bug Something isn't working label May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant