Crates.io | async-mp4 |
lib.rs | async-mp4 |
version | 0.1.1 |
source | src |
created_at | 2022-12-07 17:33:47.154746 |
updated_at | 2022-12-07 17:36:40.271456 |
description | Async Mp4 Muxer and Demuxer in pure rust |
homepage | |
repository | |
max_upload_size | |
id | 731987 |
size | 122,649 |
An mp4 muxer demuxer for mp4, made to work in WASM and async contexts.
full_box! {
box (b"mvhd", Mvhd, MvhdBox, u32)
data {
creation_time: Mp4DateTime,
modification_time: Mp4DateTime,
timescale: u32,
duration: Mp4Duration,
rate: I16F16,
volume: I8F8,
_r1: u16, // reserved
_r2: [u32; 2], // reserved
matrix: MP4Matrix,
_r3: [u32; 6], // reserved
next_track_id: u32
}
}
let ftyp = FtypBox {
major_brand: *b"iso5",
minor_version: 1,
compatible_brands: vec![*b"isom", *b"avc1", *b"iso2", *b"iso5"],
};
let moov: MoovBox = Moov {
mvhd: Some(Default::default()),
mvex: Some(Mvex {
trex: traks.iter().map(|trak| {
Trex {
track_id: trak.tkhd.as_ref().map(|it|it.track_id).unwrap_or(0),
default_sample_description_index: 1,
default_sample_duration: 0,
default_sample_size: 0,
default_sample_flags: Default::default(),
}.into()
}).collect(),
}.into()),
traks: vec![Trak { /* trak info... */ }.into()],
}.into();
let mut buf = std::io::Cursor::new(vec![]);
ftyp.write(&mut buf)?;
moov.write(&mut buf)?;
return buf.into_inner();