pub fn get_boxes_tolerant<R: Read + Seek>(
r: &mut R,
size: u64,
decode: bool,
) -> Result<(Vec<Box>, Vec<ParseIssue>)>Expand description
Like get_boxes, but recovers from malformed boxes instead of failing:
returns the tree that could be parsed together with a list of
ParseIssues (offset + description) for
everything that couldn’t.
A clean file returns an empty issue list and the same tree as
get_boxes. Damage is contained to the enclosing container: a corrupt
child abandons the rest of its container while siblings and ancestors
keep parsing, and a box whose interior fails to parse is kept as an
opaque leaf.
use mp4box::get_boxes_tolerant;
use std::fs::File;
let mut file = File::open("damaged.mp4")?;
let size = file.metadata()?.len();
let (boxes, issues) = get_boxes_tolerant(&mut file, size, true)?;
println!("parsed {} top-level boxes", boxes.len());
for issue in &issues {
eprintln!("warning: {}", issue);
}