From: Kostya Shishkov Date: Sat, 16 Nov 2019 09:00:49 +0000 (+0100) Subject: add seeking functionality X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=fde9f7c350f401dec51e6a08c4aa8134744b4b68;p=nihav-tool.git add seeking functionality --- diff --git a/src/main.rs b/src/main.rs index c26e671..784fccb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,6 +90,7 @@ fn main() { let mut decode_video = true; let mut decode_audio = true; let mut nmode = NumberMode::FrmPTS; + let mut seek_time = 0u64; while (cur_arg < args.len()) && args[cur_arg].starts_with('-') { match args[cur_arg].as_str() { @@ -100,6 +101,19 @@ fn main() { "-nm=count" => { nmode = NumberMode::Counter; }, "-nm=pktpts" => { nmode = NumberMode::PktPTS; }, "-nm=frmpts" => { nmode = NumberMode::FrmPTS; }, + "-seek" => { + cur_arg += 1; + if cur_arg == args.len() { + println!("seek time missing"); + return; + } + let ret = args[cur_arg].parse::(); + if ret.is_err() { + println!("wrong seek time"); + return; + } + seek_time = ret.unwrap(); + }, _ => { println!("unknown option {}", args[cur_arg]); return; }, } cur_arg += 1; @@ -132,6 +146,13 @@ println!("trying demuxer {} on {}", dmx_name, name); br.seek(SeekFrom::Start(0)).unwrap(); let mut dmx = create_demuxer(dmx_fact, &mut br).unwrap(); + if seek_time > 0 { + let ret = dmx.seek(seek_time); + if ret.is_err() { +println!(" seek error {:?}", ret.err().unwrap()); + } + } + let mut decs: Vec, Box)>> = Vec::new(); let mut sids: Vec = Vec::new(); let mut writers: Vec = Vec::new();