Skip to content

Packet decode return type is SubtitleSet which is too narrow. #2133

@ntjohnson1

Description

@ntjohnson1

Right now demux returns Packet which doesn't have any typing specification based on the type of Stream it holds.

def decode(self) -> list[SubtitleSet]: ...

Repro:

def test_decoded_time_base(self) -> None:
        container = av.open(fate_suite("h264/interlaced_crop.mp4"))
        stream = container.streams.video[0]

        assert stream.time_base == Fraction(1, 25)

        video_frame: av.VideoFrame | None = None

        for packet in container.demux(stream): # < - Typing returns Packet
            for frame in packet.decode(): < - Typing returns Subtitle Set (runtime returns video frame)
                video_frame = frame
                assert not isinstance(frame, SubtitleSet)
                assert packet.time_base == frame.time_base
                assert stream.time_base == frame.time_base
                return

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions