Skip to content

Video Encoder notes #1057

@NicolasHug

Description

@NicolasHug
  • let's parametrize
    def test_video_encoder_against_ffmpeg_cli(self, tmp_path, format, encode_params):
    over the other encoding methods (to_file_like, to_tensor)
  • Let's call self._get_video_metadata in this test to ensure the expected metadata is the same. We should explicitly check for duration!
  • frame_rate should accept a float. Right now it expects an int and errors on floats, but fps come in floats, like in:
import torch
from torchcodec.decoders import VideoDecoder
from torchcodec.encoders import VideoEncoder

dec = VideoDecoder("test/resources/nasa_13013.mp4")
print(dec.metadata)  # average_fps=29.xxxxx

frames = dec.get_frames_in_range(0, -1)
enc = VideoEncoder(frames.data, frame_rate=dec.metadata.average_fps))  # this currently raises an error

Let's add a test making sure we can pass a float. The test can just decode and encode nasa_13013.mp4 as done above, and assert that the encoded duration is the same as the original.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions