Repository navigation
Add Packet.from_bytes and Packet.from_tensor, and integer pts on decoded frames - #1782
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/1782
Note: Links to docs will display an error until the docs builds have been completed. ❌ 18 New Failures, 8 Unrelated FailuresAs of commit 86e1dcf 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
packet-from-bytes
branch
from
October 27, 2026 13:25
0f00707 to
cede8fd
Compare
NicolasHug
force-pushed
the
packet-from-bytes
branch
2 times, most recently
from
October 27, 2026 13:44
c9aa236 to
4db75e3
Compare
NicolasHug
force-pushed
the
packet-from-bytes
branch
from
October 27, 2026 13:54
4db75e3 to
71cabbd
Compare
NicolasHug
force-pushed
the
packet-from-bytes
branch
from
October 27, 2026 16:32
71cabbd to
b40348a
Compare
Packets can now be built from compressed data that doesn't come from a Demuxer, e.g. packets received from the network or stored in a database, together with hand-built VideoPacketDecoderParameters or AudioPacketDecoderParameters. The data is copied. pts, dts, duration, is_key_frame and side data are all optional: decoders only need the data (and pts, to report frame timestamps). In particular dts isn't needed for streams with B-frames. Packets also expose pts, dts, duration, is_key_frame, data and side_data. Since such packets go in with integer timestamps, RawFrame.pts and RawAudioSamples.pts now expose the decoded frames' pts as integers too, in the new VideoPacketDecoder.time_base / AudioPacketDecoder.time_base, or None when unknown. That's what lets users match a decoded frame to the packet timestamp they asked for exactly, rather than comparing floats. Addresses the use case of #1585.
NicolasHug
force-pushed
the
packet-from-bytes
branch
from
October 27, 2026 19:04
b40348a to
86e1dcf
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).Adds
Packet.from_bytes()andPacket.from_tensor()to build packets from compressed data that doesn't come from aDemuxer, e.g. packets from the network or from a database, as in #1585:pts,dts,duration,is_key_frameandside_dataare all optional. Decoders only need the data, plusptsto report frame timestamps. In particulardtsisn't needed for streams with B-frames: there's a test for that, CPU and CUDA.pts,dts,duration,is_key_frame,dataandside_data.RawFrame.ptsandRawAudioSamples.ptsnow expose the decoded frames' pts as integers, in the newVideoPacketDecoder.time_base/AudioPacketDecoder.time_base, orNonewhen unknown. Packets go in with integer timestamps, so this lets users match a decoded frame to the timestamp they asked for exactly, rather than reproducing our float conversion bit for bit.Addresses the use case of #1585.
Tests
pts, or no timestamps at all, decode fine.Packet.from_tensorto build packets from raw data #1585-style test: decode targets from keyframe-to-target packet windows, reusing one decoder.Stack created with GitHub Stacks CLI • Give Feedback 💬