TorchCodec 0.5 is out! This version comes with the highly requested feature: Audio Encoding!
Audio Encoding
You can now encode audio samples to a file or to raw bytes!
from torchcodec.encoders import AudioEncoder
encoder = AudioEncoder(samples=samples, sample_rate=sample_rate)
encoder.to_file("samples.mp3") # encode to a file
encoded_bytes = encoder.to_tensor(format="mp3") # encode to a tensor of bytes
Learn more in our tutorial.
Parallel video decoding
We added a new tutorial for workflows to enable parallel video decoding using multi-processing and multi-threading. Read more in our tutorial.
Additional features and improvements
-
Added a field to the Stream Metadata struct to contain sample/pixel aspect ratio to support non-square pixels.
-
Made changes to the
VideoDecoder
to be more resilient to missing metadata, specifically the number of frames in a stream or stream duration. It will use average FPS and other metadata to calculate these fields when they are missing.
Bug fixes
- A bug fix in
VideoDecoder
andAudioDecoder
when they are instantiated from bytes or a Tensor: they now adopt the data representing the video to ensure the data's lifetime matches that of the decoder.