From 4d2b5acf9e1f32ba17317beafcd38cf8238c1220 Mon Sep 17 00:00:00 2001 From: Alf Date: Wed, 27 Jan 2021 18:53:24 -0800 Subject: [PATCH] Update and add example for Mp4Writer.into_writer. --- examples/mp4writer.rs | 24 ++++++++++++++++++++++++ src/writer.rs | 10 +++++----- 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 examples/mp4writer.rs diff --git a/examples/mp4writer.rs b/examples/mp4writer.rs new file mode 100644 index 0000000..5e721d2 --- /dev/null +++ b/examples/mp4writer.rs @@ -0,0 +1,24 @@ +use mp4::{Mp4Config, Mp4Writer}; +use std::io::Cursor; + +fn main() -> mp4::Result<()> { + let config = Mp4Config { + major_brand: str::parse("isom").unwrap(), + minor_version: 512, + compatible_brands: vec![ + str::parse("isom").unwrap(), + str::parse("iso2").unwrap(), + str::parse("avc1").unwrap(), + str::parse("mp41").unwrap(), + ], + timescale: 1000, + }; + + let data = Cursor::new(Vec::::new()); + let mut writer = Mp4Writer::write_start(data, &config)?; + writer.write_end()?; + + let data: Vec = writer.into_writer().into_inner(); + println!("{:?}", data); + Ok(()) +} \ No newline at end of file diff --git a/src/writer.rs b/src/writer.rs index dc169d2..5c946f6 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -36,13 +36,13 @@ impl Mp4Writer { /// /// # fn main() -> mp4::Result<()> { /// let config = Mp4Config { - /// major_brand: "isom / 0x69736F6D".into(), + /// major_brand: str::parse("isom").unwrap(), /// minor_version: 512, /// compatible_brands: vec![ - /// "isom".into(), - /// "iso2".into(), - /// "avc1".into(), - /// "mp41".into(), + /// str::parse("isom").unwrap(), + /// str::parse("iso2").unwrap(), + /// str::parse("avc1").unwrap(), + /// str::parse("mp41").unwrap(), /// ], /// timescale: 1000, /// };