Skip to main content

ffmpeg_packet_from_video_packet

Function ffmpeg_packet_from_video_packet 

Source
pub fn ffmpeg_packet_from_video_packet(
    packet: &VideoPacket<VideoPacketExtra, FfmpegBuffer>,
) -> Result<Packet, PacketBuildError>
Expand description

Builds an ffmpeg::Packet from a [mediadecode::VideoPacket] parameterized by crate::extras::VideoPacketExtra and crate::FfmpegBuffer.

The compressed bytes are copied into a new packet allocation — zero-copy passthrough of the FfmpegBuffer’s underlying AVBufferRef is a future optimization (would need to wire an AVBufferRef into AVPacket.buf directly via av_packet_alloc + manual buffer set). PTS / DTS / duration / flags / stream_index are propagated.

Side data on the extras is reattached to the rebuilt packet — see [attach_side_data] for why that is not optional.

Returns PacketBuildError on:

  • payload larger than c_int::MAX (would overflow AVPacket.size);
  • av_new_packet allocation failure (OOM);
  • a side-data entry this build of FFmpeg cannot name, or one whose allocation failed.