pub fn video_frame_from(
frame: &Frame,
time_base: Timebase,
limits: FrameLimits,
) -> Result<VideoFrame<PixelFormat, VideoFrameExtra, FfmpegBytes>, ConvertError>Expand description
Safe wrapper around av_frame_to_video_frame taking a borrowed
ffmpeg::Frame. Recommended entry point for
most callers — equivalent to passing frame.as_ptr() to the
unsafe variant, but the FFmpeg side keeps the frame alive for the
duration of the call so the safety contract is satisfied
internally.
Borrowed source, owned lane. This road copies, on purpose and
without a lane to choose. ffmpeg_next’s frame wrappers lend
&mut [u8] through data_mut and share their buffers by refcount
with no copy-on-write, so a caller who still holds the frame holds a
mutable alias of every byte a view would read — and both sides are
Send, so the two halves need not even be on one thread. No safe
signature that borrows a frame can hand out a window onto it.
The view lane reaches frames the way it is meant to: through a
decoder, which owns the AVFrame it decoded into and never lends it
out. A caller holding an AVFrame of their own can use the unsafe
entry point below, whose contract names the obligation this
signature cannot express.
The lane is not a parameter here, and asking for one does not
compile:
use mediadecode_ffmpeg::{FrameLimits, View, convert::video_frame_from};
let frame = ffmpeg_next::frame::Video::new(ffmpeg_next::format::Pixel::GRAY8, 64, 4);
let _ = video_frame_from::<View>(&frame, mediadecode::Timebase::default(), FrameLimits::default());