From: Kostya Shishkov Date: Fri, 1 May 2020 15:17:10 +0000 (+0200) Subject: allow dumping raw frames X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=2299da077b933c0930c2b0edf2b4288a2d77741b;p=nihav-tool.git allow dumping raw frames --- diff --git a/src/main.rs b/src/main.rs index bb94c12..59c1878 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ extern crate nihav_core; extern crate nihav_registry; extern crate nihav_allstuff; -use std::io::SeekFrom; +use std::io::{SeekFrom, Write}; use std::fs::File; use std::path::Path; use nihav_core::io::byteio::{FileReader, ByteReader}; @@ -95,6 +95,7 @@ fn main() { let mut vpfx: Option = None; let mut apfx: Option<&str> = None; let mut ignore_errors = false; + let mut dump_frames = false; while (cur_arg < args.len()) && args[cur_arg].starts_with('-') { match args[cur_arg].as_str() { @@ -135,6 +136,7 @@ fn main() { vpfx = Some(args[cur_arg].clone()); }, "-ignerr" => { ignore_errors = true; }, + "-dumpfrm" => { dump_frames = true; }, _ => { println!("unknown option {}", args[cur_arg]); return; }, } cur_arg += 1; @@ -233,6 +235,7 @@ panic!("decoder {} not found", info.get_name()); } } + let mut frmnum = 0; loop { let pktres = dmx.get_frame(); if let Err(e) = pktres { @@ -242,6 +245,12 @@ panic!("decoder {} not found", info.get_name()); let streamno = pkt.get_stream().get_id(); let sr = sids.iter().position(|x| *x == streamno); let idx = sr.unwrap(); + if dump_frames { + let name = format!("out{:02}_{:08}.frm", streamno, pkt.get_pts().unwrap_or(frmnum)); + let mut ofile = File::create(name).unwrap(); + ofile.write(pkt.get_buffer().as_slice()).unwrap(); + frmnum += 1; + } if let Some((ref mut dsupp, ref mut dec)) = decs[idx] { match dec.decode(dsupp, &pkt) { Ok(frm) => {