TorchCodec 0.3.0 is out! It comes with two new major features: Audio decoding, and Streaming.
Audio decoding
You can now decode audio streams from videos, or from audio files! The AudioDecoder
looks a lot like the existing VideoDecoder
:
from torchcodec.decoders import AudioDecoder
decoder = AudioDecoder(path_to_audio)
samples = decoder.get_all_samples()
print(samples)
# AudioSamples:
# data (shape): torch.Size([2, 4297722])
# pts_seconds: 0.02505668934240363
# duration_seconds: 97.45401360544217
# sample_rate: 44100
Lean more in our tutorial.
Streaming
You can now decode steaming videos and audio! That is, when files do not reside locally, TorchCodec now supports downloading only the data segments that are needed to decode the frames you care about. The API is generic and integrates nicely with existing file-like interfaces like fsspec
and others.
Learn more in our tutorial.