Skip to content

msd/python demuxer - #1679

Open
NicolasHug wants to merge 1 commit into
msd/cpp-cached-scanfrom
msd/python-demuxer
Open

msd/python demuxer#1679
NicolasHug wants to merge 1 commit into
msd/cpp-cached-scanfrom
msd/python-demuxer

Conversation

@NicolasHug

Copy link
Copy Markdown
Contributor

Stack created with GitHub Stacks CLIGive Feedback 💬

@pytorch-bot

pytorch-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/meta-pytorch/torchcodec/1679

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 1 Unrelated Failure

As of commit 7b1883e with merge base 0d3103d (image):

NEW FAILURE - The following job has failed:

BROKEN TRUNK - The following job 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.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 1, 2026
@NicolasHug
NicolasHug force-pushed the msd/python-demuxer branch 2 times, most recently from a0b1b60 to cd6ec59 Compare September 2, 2026 12:52
Demuxer(source, streams=...) is the user-facing half of the multi-stream
work. Streams are chosen once, at construction, and never change:

    demuxer = Demuxer("video.mp4", streams=("video", "audio"))
    video, audio = demuxer.streams
    decoders = {s.index: s.make_decoder() for s in demuxer.streams}

    for packet in demuxer:
        decoder = decoders[packet.stream_index]
        for out in (decoder.drain() if packet.is_eof
                    else decoder.decode(packet)):
            ...

A selector is "video", "audio" or an int container index, alone or in a
tuple, plus a standalone "all" for every audio and video stream. The order
given is the order of .streams. Selecting the same stream twice raises, as
does selecting a subtitle or data stream - "all" is the way to say "skip
those" rather than "report them".

Streams are objects rather than bare indices because scan() belongs to video
and to nothing else: VideoStream has it, AudioStream simply doesn't, so the
rule is enforced by the type rather than by an error message. They are also
where make_decoder() lives, so a decoder is built from the stream it decodes
and no second container is opened.

seek() takes the stream to resolve against. FFmpeg resolves a seek in one
stream's time base and lands on that stream's keyframes, so with two video
streams only the named one is exact - the docstring says so rather than
implying both are equally seekable. We deliberately do not seek to
"somewhere safe for everything": that needs keyframe knowledge we don't
always have, and it would silently land earlier than asked.

VideoDemuxer and AudioDemuxer are now Demuxer pinned to one stream, and
behave as before. Their packet decoders keep public constructors for now:
removing those is tied to whether these two classes survive at all, which is
still open.

New op _blocks_demuxer_stream_media_types reports each stream's media type,
so selectors resolve without opening the container twice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant