Repository navigation
Build packet decoders from decoder parameters - #1780
Draft
NicolasHug wants to merge 1 commit into
Draft
NicolasHug wants to merge 1 commit into
NicolasHug wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/meta-pytorch/torchcodec/1780
Note: Links to docs will display an error until the docs builds have been completed. ❌ 11 New Failures, 8 Unrelated FailuresAs of commit 2141766 with merge base ffb098a ( NEW FAILURES - The following jobs have failed:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
NicolasHug
force-pushed
the
decoder-parameters
branch
from
October 27, 2026 13:25
49f4a2d to
cb3d2b6
Compare
This was referenced Oct 27, 2026
NicolasHug
force-pushed
the
decoder-parameters
branch
2 times, most recently
from
October 27, 2026 13:44
21b0e2f to
b6b975a
Compare
NicolasHug
force-pushed
the
decoder-parameters
branch
2 times, most recently
from
October 27, 2026 16:32
92b7200 to
f1c02a9
Compare
VideoPacketDecoder(parameters, device, *, num_ffmpeg_threads, decoder) and AudioPacketDecoder(parameters, *, decoder) can now be built directly from VideoPacketDecoderParameters / AudioPacketDecoderParameters, whether they come from a stream or are built by hand. stream.make_decoder() goes through the same path, so a demuxed stream and its parameters can't decode differently. decoder= selects a specific FFmpeg decoder. Invalid parameters (unknown codec, enum name or field) raise when building the decoder. On the C++ side, PacketDecoder is now built from DecoderParameters instead of a Demuxer, and so is the device interface: DeviceInterface::initialize_video_decoding() takes DecoderParameters instead of an AVStream and AVFormatContext. This breaks out-of-tree device interfaces that override it. Since there may not be a container anymore, NVDEC no longer picks its bitstream filter from the container name: the mp4toannexb filters are applied when the extradata isn't Annex B, the same check those filters make, and mpeg4_unpack_bframes is applied to every MPEG-4 stream (it passes through packets that aren't packed). Part of #1585.
NicolasHug
force-pushed
the
decoder-parameters
branch
from
October 27, 2026 19:04
f1c02a9 to
2141766
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is part of a stack that adds demuxer-free decoding to the low-level APIs: decoding packets that don't come from a
Demuxer(#1585), demuxing and decoding in different processes, and raw H.264 / HEVC streams (#1771).VideoPacketDecoderandAudioPacketDecodercan now be built directly from the decoder parameters added in #1779, whether they come from a stream or are built by hand:stream.make_decoder()goes through the same path, so a demuxed stream and its parameters can't decode differently.decoder=selects a specific FFmpeg decoder, which must decode the parameters' codec.framerateneeds FFmpeg 6 andcoded_side_dataneeds FFmpeg 6.1; setting them on older versions raises.C++ changes worth a look
DemuxerinPacketDecoder: it's built fromDecoderParameters.DeviceInterface::initialize_video_decoding()(andinitialize_video()) take theDecoderParametersinstead of anAVStreamand anAVFormatContext, so out-of-tree interfaces that override it need updating. The in-tree third-party interface test doesn't override it.SingleStreamDecoderbuilds itsDecoderParametersfrom its stream with the sameget_decoder_parameters()as theDemuxerpath.h264_mp4toannexb/hevc_mp4toannexbare now applied when the extradata isn't Annex B, using the same check as the filters themselves: Annex B extradata is empty or starts with a start code.mpeg4_unpack_bframesis now applied to every MPEG-4 stream, not just AVI ones. It passes any packet that isn't DivX-packed through unchanged.Part of #1585.
Tests
codecandtime_base, PCM. CPU and CUDA. The CUDA cases go through the extradata-based filter choice.decoder=.Stack created with GitHub Stacks CLI • Give Feedback 💬