mirror of
https://github.com/alfg/mp4-rust.git
synced 2024-12-22 12:06:33 +00:00
Update and add example for Mp4Writer<W>.into_writer.
This commit is contained in:
parent
8fd133eccf
commit
4d2b5acf9e
2 changed files with 29 additions and 5 deletions
24
examples/mp4writer.rs
Normal file
24
examples/mp4writer.rs
Normal file
|
@ -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::<u8>::new());
|
||||
let mut writer = Mp4Writer::write_start(data, &config)?;
|
||||
writer.write_end()?;
|
||||
|
||||
let data: Vec<u8> = writer.into_writer().into_inner();
|
||||
println!("{:?}", data);
|
||||
Ok(())
|
||||
}
|
|
@ -36,13 +36,13 @@ impl<W> Mp4Writer<W> {
|
|||
///
|
||||
/// # 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,
|
||||
/// };
|
||||
|
|
Loading…
Reference in a new issue