forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB86fb0f3Tahinli7 days ago3927 commits

dump.rs44 lines, 1.3 KiBHistoryRawDownload
1//! Lists the programs, tracks and streams of a transport stream and counts its
2//! packets: `cargo run -p ec-mpegts --example dump -- file.m2ts`.
3
4use std::fs::File;
5use std::io::BufReader;
6
7use ec_core::registry::Demuxer;
8use ec_mpegts::TsDemuxer;
9
10fn main() {
11 let path = std::env::args().nth(1).expect("usage: dump <file>");
12 let mut d = TsDemuxer::new(BufReader::new(File::open(&path).expect("open"))).expect("demux");
13 println!("packet size {} bdav {}", d.packet_size(), d.is_bdav());
14 for p in d.programs() {
15 println!(
16 "program {} pmt {:#x} pcr {:?} streams {}",
17 p.number,
18 p.pmt_pid,
19 p.pcr_pid,
20 p.streams.len()
21 );
22 }
23 for t in d.tracks() {
24 println!(
25 "track pid {:#x} type {:#x} {:?} stream {:?} refusal {:?}",
26 t.pid, t.stream_type, t.kind, t.stream, t.refusal
27 );
28 }
29 for s in d.streams() {
30 println!(
31 "stream {} {} start {:?} duration {:?}",
32 s.index,
33 s.params.codec.name(),
34 s.start_time,
35 s.duration
36 );
37 }
38 println!("duration {:?}", d.duration_secs());
39 let mut counts = vec![0u64; d.streams().len()];
40 while let Ok(p) = d.next_packet() {
41 counts[p.stream as usize] += 1;
42 }
43 println!("packets {counts:?} stats {:?}", d.stats());
44}