-
Notifications
You must be signed in to change notification settings - Fork 70
Description
We create/allocate output frame tensors in different places. In particular, we determine the height and width of the output tensor from different sources:
- For batch APIs (CPU and GPU): from the stream metadata, which itself comes from the
CodecContext - For single frame APIs:
- CPU: swscale and filtergraph: from the
AVFrame - GPU: from the
CodecContext
- CPU: swscale and filtergraph: from the
The info from the metadata / CodecContext are available as soon as we add a stream, e.g. right after we instantiate a Python VideoDecoder. The AVFrame is only available once we have decoded the frame with ffmpeg (this is the "raw output").
The source of truth really is the AVFrame. CondecContext may be wrong, and in particular we now know that some streams may have variable height and width #312.
Details:
- For batch APIs:
-
For single frames APIs: https://github.com/pytorch/torchcodec/blob/41c6491d81e00f47529074ca1c78217cc03fc0ea/src/torchcodec/decoders/_core/VideoDecoder.cpp#L887-L890
and https://github.com/pytorch/torchcodec/blob/41c6491d81e00f47529074ca1c78217cc03fc0ea/src/torchcodec/decoders/_core/VideoDecoder.cpp#L1279-L1286