Skip to content

ZeroDivisionError when accessing metadata #676

Closed
@NicolasHug

Description

@NicolasHug

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 )


Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions