forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits

audio_open_cost.rs29 lines, 1.2 KiBHistoryRawDownload
1//! What one open of a Matroska file's *sound* costs -- the walk the `Cues` do
2//! not answer, since Matroska indexes no audio samples at all.
3//!
4//! `cargo run --release -p engine --example audio_open_cost -- <file> [repeats]`
5//!
6//! Prints one line per open in milliseconds and the block count it found; the
7//! first line is the cold one (no sidecar yet), the rest are what a reopen costs
8//! once the walk has been written down.
9
10use std::path::PathBuf;
11use std::time::Instant;
12
13fn main() {
14 let mut args = std::env::args_os().skip(1);
15 let path = PathBuf::from(args.next().expect("usage: audio_open_cost <file> [repeats]"));
16 let repeats: usize = args
17 .next()
18 .and_then(|s| s.to_str().and_then(|s| s.parse().ok()))
19 .unwrap_or(3);
20 for i in 0..repeats {
21 let start = Instant::now();
22 let audio = engine::demux::MkvAudio::open(&path).expect("open the sound track");
23 let ms = start.elapsed().as_secs_f64() * 1e3;
24 match audio {
25 Some(audio) => println!("audio open {i}: {ms:.1} ms ({} blocks)", audio.blocks()),
26 None => println!("audio open {i}: {ms:.1} ms (no AC-3 track)"),
27 }
28 }
29}