meta-pytorch / meta-pytorch/torchcodec
Support for Passing Codec-Specific Options
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 125
- Avg merge
- 22h 47m
- Merged PRs (30d)
- 54
Description
TorchCodec currently provides no way to forward codec-specific parameters to libavcodec when initializing a decoder via avcodec_open2. This limits advanced use cases that require control over backend behavior, decoding quality, or performance tuning.
TorchCodec embeds FFmpeg's libavcodec into its native C++ backend (_core). When a video stream is added, VideoStreamOptions is populated by custom_ops.cpp (Python binding) with preset fields:
Width, height
Thread count
Dimension order
Optional color-conversion library
Target device
These are passed to SingleStreamDecoder::addVideoStream, which sets up the decoder and calls:
avcodec_open2(codec_context, codec, /* options = */ nullptr);
Since no AVDictionary is passed, libavcodec uses default settings. This prevents codecs from receiving extra options.
Proposed Solution
To enable codec-specific parameter forwarding:
Extend VideoStreamOptions
Add new fields (or a generic options dictionary) for key-value parameters.
Update custom_ops.cpp
Modify the Python binding to accept and forward these additional options from Python to C++.
Update SingleStreamDecoder
Construct an AVDictionary* from the new options.
Pass it to avcodec_open2() as the third parameter.
Benefit
This enables users to:
Fine-tune codec behavior
Make TorchCodec more extensible and FFmpeg-aligned
Willing to Contribute
Yes – I’m interested in implementing this feature and can start with guidance or approval from maintainers.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with VideoStreamOptions population in custom_ops.cpp and follow it into SingleStreamDecoder::addVideoStream. Trace the existing avcodec_open2 call, then define how Python key-value options become an AVDictionary and verify that codec-specific options are forwarded when the decoder opens.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python, pytorch
- Domain
- audio-video-rtc, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100