Create test tool to deconstruct and reassemble a WebM file

This commit is contained in:
Tangent 128 2017-09-05 00:17:11 -04:00
parent 93883e2683
commit 271782bb91
1 changed files with 49 additions and 0 deletions

49
src/bin/resynth.rs Normal file
View File

@ -0,0 +1,49 @@
extern crate lab_ebml;
use std::io::{Cursor, stdout, Write};
use lab_ebml::Schema;
use lab_ebml::webm::*;
use lab_ebml::webm::WebmElement::*;
const SRC_FILE: &'static [u8] = include_bytes!("../data/test1.webm");
pub fn main() {
let mut head = Vec::new();
let mut body = Vec::new();
let mut reading_head = true;
for element in Webm.parse(SRC_FILE) {
match element {
Cluster => reading_head = false,
// TODO: skip elements not required for streaming
Info => continue,
Void => continue,
Unknown(_) => continue,
_ => (),
}
if reading_head {
head.push(element);
} else {
body.push(element);
}
}
let mut output = Vec::new();
let mut cursor = Cursor::new(output);
for element in head {
encode_webm_element(element, &mut cursor).unwrap();
}
for element in body {
encode_webm_element(element, &mut cursor).unwrap();
}
output = cursor.into_inner();
stdout().write_all(&output).unwrap();
output.clear();
}