Skip to main content

video_packet_from_ffmpeg

Function video_packet_from_ffmpeg 

Source
pub fn video_packet_from_ffmpeg(
    packet: &Packet,
) -> Result<Option<VideoPacket<VideoPacketExtra, FfmpegBytes>>, PacketBufferError>
Expand description

Carries a borrowed [ffmpeg::Packet] out as a mediadecode::packet::VideoPacket on the view lane: the payload is a refcounted window onto the source AVPacket’s own buffer, which is why the delivered packet’s lifetime is answerable to libavformat’s — see the two carrier lanes. For a packet that must outlive the demuxer, ask for the owned lane by name: video_packet_from_ffmpeg_as::<Owned>, whose payload is copied and which the D-seat amputation contract governs.

Timestamps, duration, key/corrupt flags, and the source stream index are forwarded to the produced packet.

Uses the default PacketLimits; the _in sibling takes them explicitly, alongside the stream’s timebase.

Returns Ok(None) when the source packet has no payload at all (an empty packet — typical after EOF), and PacketBufferError when a payload that is there could not be carried — over budget, or claiming bytes outside its own buffer. Those are never the same answer. Caller can also fill in VideoPacketExtra::byte_pos / side_data post-construction if they need those.