forked from mozilla/mp4parse-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump.rs
36 lines (32 loc) · 951 Bytes
/
dump.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
extern crate mp4parse;
use std::env;
use std::fs::File;
use std::io::BufReader;
extern crate byteorder;
fn dump_file(filename: &String) {
let file = File::open(filename).unwrap();
let mut reader = BufReader::new(file);
let mut context = mp4parse::MediaContext::new();
// Turn on debug output.
context.trace(true);
// Read all boxes.
match mp4parse::read_mp4(&mut reader, &mut context) {
Ok(_) => {},
Err(mp4parse::Error::UnexpectedEOF) => {},
Err(mp4parse::Error::Io(e)) => {
println!("I/O ERROR: {:?}", e);
panic!(e);
},
Err(e) => {
println!("ERROR: {:?}", e);
},
}
println!("-- result of parsing '{}' --\n{:?}", filename, context);
}
fn main() {
for filename in env::args().skip(1) {
println!("-- dump of '{}' --", filename);
dump_file(&filename);
println!("-- end of '{}' --", filename);
}
}