Rate this Page

VideoStream#

class torchcodec.encoders.VideoStream(encoder_tensor: Tensor, stream_index: int)[source]#

A video stream within an Encoder.

Returned by Encoder.add_video(). Use add_frames() to feed video frames into this stream.

Examples using VideoStream:

Encoding audio and video streams with the Encoder

Encoding audio and video streams with the Encoder

Encoding video with the Encoder

Encoding video with the Encoder
add_frames(frames: Tensor) None[source]#

Add video frames to this stream.

Parameters:

frames (torch.Tensor) – The frames to encode. This must be a 4D tensor of shape (N, C, H, W) where N is the number of frames, C is 3 channels (RGB), H is height, and W is width. Values must be uint8 in the range [0, 255]. The device of the tensor must match the device passed to Encoder.add_video().