decode_frames

Function decode_frames 

Source
pub fn decode_frames(
    data_uri: &str,
    target_fps: f32,
    ffmpeg: &FfmpegPolicy,
) -> Result<(Vec<RgbImage>, f32)>
Expand description

Decode every frame of a container, choosing a backend by what the bytes actually are.

Returns the frames and the rate they represent. GIF is decoded in-process (pure Rust, no dependency) and reports the container’s own average rate, so the caller still has to sample it. ffmpeg resamples during decode, so its frames are ALREADY at target_fps and it reports that — which makes the caller’s sampling step a no-op rather than a second, lossy resample.

Dispatch is on MAGIC BYTES, not the declared MIME. A client that labels an mp4 video/gif, or sends application/octet-stream, still gets the right decoder; and a GIF mislabelled as mp4 does not needlessly spawn a process.