inspect_annex_b/
inspect_annex_b.rs1use std::{env, fs};
2
3use openipc_video::{codecs::annex_b, CodecConfigTracker, ConfigUpdate, VideoCodec};
4
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let mut args = env::args().skip(1);
7 let codec = match args.next().as_deref() {
8 Some("h264") => VideoCodec::H264,
9 Some("h265") | Some("hevc") => VideoCodec::H265,
10 _ => return Err("usage: inspect_annex_b <h264|h265> <access-unit-file>".into()),
11 };
12 let path = args
13 .next()
14 .ok_or("usage: inspect_annex_b <h264|h265> <access-unit-file>")?;
15 let data = fs::read(path)?;
16 let units = annex_b::nal_units(&data)?;
17 let mut tracker = CodecConfigTracker::default();
18 let config = tracker.observe(codec, &data)?;
19
20 println!(
21 "codec={codec} bytes={} nal_units={}",
22 data.len(),
23 units.len()
24 );
25 println!(
26 "configuration={}",
27 match config {
28 ConfigUpdate::Incomplete => "incomplete",
29 ConfigUpdate::Unchanged => "unchanged",
30 ConfigUpdate::Changed(_) => "complete",
31 }
32 );
33 Ok(())
34}