use bxs; use bxs::Bx; use std::fs; fn main() { let mut segment = bxs::MediaSegment::default(); // audio traf let mut traf = bxs::TrackFragment::new(1); traf.tfhd_bx.default_sample_duration = Some(1024); traf.trun_bx.data_offset = Some(0); // dummy traf.trun_bx.samples.push(bxs::Sample::with_size(100)); traf.trun_bx.samples.push(bxs::Sample::with_size(100)); segment.moof_bx.traf_bxs.push(traf); segment.moof_bx.traf_bxs[0].trun_bx.data_offset = Some(segment.moof_bx.size() as i32 + 8); let size = segment.moof_bx.size(); _ = fs::remove_file("/tmp/audio.m4a"); let file = fs::File::create("/tmp/audio.m4a").expect("created"); segment.write_to(&file).unwrap(); println!("size {size}"); }