aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2020-07-09 10:44:05 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2020-07-09 10:44:05 +0200
commit7cd3b41eda101ea5b3e36d73436c68a5b5d4f030 (patch)
tree0ef7d87124c2a569b862ef7b1b5bb8e8a3cbd09f
parent69524874857bc441acc89c768e6cc7095f615a17 (diff)
downloadnihav-tool-7cd3b41eda101ea5b3e36d73436c68a5b5d4f030.tar.gz
switch seeking and end time to use NATimePoint
-rw-r--r--src/main.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index 1be4e2a..79212fd 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -77,14 +77,14 @@ fn main() {
println!("usage: nihav-tool [-noout] [-vn] [-an] input [lastpts]");
return;
}
- let mut lastpts: Option<u64> = None;
+ let mut lastpts = NATimePoint::None;
let mut cur_arg: usize = 1;
let mut noout = false;
let mut decode_video = true;
let mut decode_audio = true;
let mut nmode = NumberMode::FrmPTS;
let mut smode = FrameSkipMode::None;
- let mut seek_time = 0u64;
+ let mut seek_time = NATimePoint::None;
let mut vpfx: Option<String> = None;
let mut apfx: Option<&str> = None;
let mut ignore_errors = false;
@@ -107,7 +107,7 @@ fn main() {
println!("seek time missing");
return;
}
- let ret = args[cur_arg].parse::<u64>();
+ let ret = args[cur_arg].parse::<NATimePoint>();
if ret.is_err() {
println!("wrong seek time");
return;
@@ -139,7 +139,12 @@ fn main() {
let name = args[cur_arg].as_str();
cur_arg += 1;
if cur_arg < args.len() {
- lastpts = Some(u64::from_str_radix(args[cur_arg].as_str(), 10).unwrap());
+ let ret = args[cur_arg].parse::<NATimePoint>();
+ if ret.is_err() {
+ println!("cannot parse end time");
+ return;
+ }
+ lastpts = ret.unwrap();
}
let path = Path::new(name);
@@ -164,7 +169,7 @@ 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 {
+ if seek_time != NATimePoint::None {
let ret = dmx.seek(seek_time);
if ret.is_err() {
println!(" seek error {:?}", ret.err().unwrap());
@@ -259,7 +264,7 @@ panic!("decoder {} not found", info.get_name());
};
}
},
- Err(DecoderError::MissingReference) if seek_time > 0 => {
+ Err(DecoderError::MissingReference) if seek_time != NATimePoint::None => {
println!("ignoring missing ref");
},
Err(reason) => {
@@ -269,7 +274,7 @@ panic!("decoder {} not found", info.get_name());
}
},
};
- if pkt.get_pts() != None && lastpts.is_some() && pkt.get_pts() >= lastpts { break; }
+ if pkt.get_pts() != None && lastpts != NATimePoint::None && !pkt.ts.less_than(lastpts) { break; }
}
}
//panic!("end");