Skip to content

TorchCodec 0.9

Latest

Choose a tag to compare

@Dan-Flores Dan-Flores released this 04 Dec 19:57
· 11 commits to main since this release
ce82c7c

TorchCodec 0.9 is out! This comes with a new highly requested feature: video encoding!

Video Encoding

Video encoding on CPU is available. It provides a simple API to encode video frames to tensors or bytes, and optionally enables a set of key parameters.

from torchcodec.encoders import VideoEncoder

encoder = VideoEncoder(frames=frame_tensor, frame_rate=frame_rate)

encoder.to_file(dest="output.mp4") # encode to mp4 file
encoded_bytes = encoder.to_tensor(format="mp4") # encode to tensor of bytes

Additionally, several key parameters are exposed to control the encoded video:

# Utilize a specific codec, choose a pixel format to control quality
encoder.to_file(dest="output.mp4", codec="libx264", pixel_format="yuv420p")
 
# Set quality parameter `crf` to 0 for lossless encoding, use fast `preset`
encoded_bytes = encoder.to_tensor(format="mp4", crf=0, preset="fast")

Read more about the available features in the video encoding tutorial!

Enhancements

  • This release adds support for Python 3.14!
  • #989: Improved VideoDecoder metadata, enabling seek_mode=approximate for some videos with missing metadata.
  • #1028: Enhanced video decoding speed up to 1.5x when decoding frames sequentially with seek_mode="approximate".
  • #1078: Updated guidance on when to use approximate mode in the tutorial.

Bug fixes

  • #1025: Fixed bug: passing device=None in VideoDecoder now uses the current torch device.