From fde9f7c350f401dec51e6a08c4aa8134744b4b68 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 16 Nov 2019 10:00:49 +0100 Subject: [PATCH] add seeking functionality --- src/main.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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(); -- 2.39.5