Add Packet.from_tensor to build packets from raw data - #1585
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/meta-pytorch/torchcodec/1585
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hi @oxkitsune! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Hi @oxkitsune , thanks for the PR and for your interest in the these new APIs! They are still very WIP and subject to change (and not public!) so I'd love to learn more about your use for it? On the PR itself, I'm open to it and to support that feature in general, but I won't merge it now because I plan to continue working (and heavily changing) these APIs in the near future. I also suspect we'll be supporting a file-like input in the |
|
Hi @NicolasHug, these new APIs are awesome!
This sounds great! Looking forward to it. If there's anything I can help out with, let me know! |
|
Thanks! Can you share more on why the |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
You're right that missing duration metadata is one of the blockers (
Yea! Our use case is a bit different than the usual one I guess 😄 Some context on our setup: Rerun stores video as raw codec packets (Annex B / OBUs) in a database, one packet per row keyed by timestamp, with keyframe flags in a separate column. There is no file. With the current file-like input API we need to wrap the window of packets (keyframe to target frame) in an in-memory MP4 container in order to feed it to a So what I'd love from a packet-level API is the ability to feed raw packets (with keyframe/PTS info) into a decoder object, ask for decoded frames as tensors, and ideally be able to keep feeding packets to an existing instance. |
What
Packets could previously only be obtained from a
Demuxer.This adds
Packet.from_bytesandPacket.from_tensorto construct aPacketdirectly from raw compressed data (e.g. from a network stream), with caller-providedpts,duration, andis_key_frame.ptsanddurationare in the consuming decoder's stream time base.dtsis set topts, so this is only correct for streams without B-frame reordering.