Skip to main content

load_mp4_from_bytes

Function load_mp4_from_bytes 

Source
pub fn load_mp4_from_bytes(
    bytes: Vec<u8>,
    config: &Mp4Config,
    entity_path: &EntityPath,
    debug_name: &str,
) -> Result<impl Iterator<Item = Result<Chunk, Mp4Error>> + use<>, Mp4Error>
Expand description

Load mp4 bytes from memory and return an iterator of chunks.

The returned iterator is lazy: chunks are constructed one at a time as it is drained. The item type is Result<Chunk, Mp4Error> because constructing an individual chunk can fail mid-stream; it is up to the caller to decide whether to abort or skip on Err. Note that unreadable frame timestamps are not surfaced as an Err item — that case is handled leniently by emitting only the asset chunk.

debug_name is a human-readable label for the video (e.g. its source path or URL) used only in log and panic messages — it has no effect on decoding.

Unlike the path-based load_mp4, the bytes are already in memory here, so Mode::Stream reads samples from the in-memory buffer rather than streaming from disk.