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>,
    limits: PacketLimits,
) -> Result<Packet, PacketBuildError>
Expand description

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

The compressed bytes are copied into a new packet allocation. The return leg copies for the same reason the outbound one does: the carrier is Rust-owned memory with no AVBufferRef behind it to hand back. 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.