pub struct Frame {
pub timestamp: Timestamp,
pub size: Size,
pub surface: Surface,
}Expand description
A decoded raw video frame: CPU I420, or a GPU frame when a hardware decoder produced one (NVDEC on Linux).
A GPU frame stays on the GPU until something needs bytes: feeding it to
encode::Encoder::encode keeps it there
(the zero-copy transcode path), while Surface::into_i420
downloads it.
Fields§
§timestamp: TimestampPresentation timestamp, carried through from the container. It rides out of the decoder with each picture, so a reordered frame (B-frames) keeps its own time rather than the input access unit’s.
size: SizeThe decoded resolution, which is Config::resize when the backend
honored it and the stream’s native size otherwise.
surface: SurfaceWhere the pixels live. Match on it for a zero-copy path, or call
Surface::into_i420 for the universal one.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn resize(&self, size: Size) -> Result<Frame, Error>
pub fn resize(&self, size: Size) -> Result<Frame, Error>
A copy of this frame scaled to size (both dimensions even and non-zero),
preserving the timestamp. A CUDA frame scales on the GPU (a box filter,
correct at any downscale factor) and stays there, so resize ->
encode never touches the CPU. Every
other frame scales on the CPU, which for a CVPixelBuffer means a
download first. When one output size is enough, prefer decoding
straight to it (Config::resize), which is free on decoders with a
hardware scaler; this method is for fanning one decoded stream out to
several sizes.