aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2022-12-10 09:47:40 +0100
committerKostya Shishkov <kostya.shishkov@gmail.com>2022-12-10 09:47:40 +0100
commit8a8f6e5c8847945e274c5d7e2c6a51c027c19c35 (patch)
tree41f400f326d4839e09e1cf67409b79cf3038dfc7
parent033d6b00ff1e99afb0304800fa1b20322933a5c5 (diff)
downloadnihav-tool-8a8f6e5c8847945e274c5d7e2c6a51c027c19c35.tar.gz
add option for forcing demuxer
-rw-r--r--src/demux.rs12
-rw-r--r--src/main.rs11
2 files changed, 21 insertions, 2 deletions
diff --git a/src/demux.rs b/src/demux.rs
index 0786275..56659c7 100644
--- a/src/demux.rs
+++ b/src/demux.rs
@@ -98,9 +98,19 @@ pub enum DemuxerObject<'a> {
}
impl<'a> DemuxerObject<'a> {
- pub fn create(br: &'a mut ByteReader<'a>, reg: &FullRegister, name: &str, is_raw: bool) -> DemuxerObject<'a> {
+ pub fn create(br: &'a mut ByteReader<'a>, reg: &FullRegister, name: &str, force_dmx: Option<&str>, is_raw: bool) -> DemuxerObject<'a> {
if !is_raw {
let res = detect::detect_format(name, br);
+ if let Some(dmx_name) = force_dmx {
+ println!("forcing demuxer {} on {}", dmx_name, name);
+ if let Some(dmx_fact) = reg.dmx_reg.find_demuxer(dmx_name) {
+ br.seek(SeekFrom::Start(0)).unwrap();
+ let dmx = create_demuxer(dmx_fact, br).unwrap();
+ return DemuxerObject::Normal(dmx);
+ } else {
+ return DemuxerObject::None
+ }
+ }
let (dmx_name, _) = res.unwrap_or(("", detect::DetectionScore::No));
if dmx_name != "" {
println!("trying demuxer {} on {}", dmx_name, name);
diff --git a/src/main.rs b/src/main.rs
index 8280799..929ab6e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -104,6 +104,7 @@ fn main() {
let mut apfx: Option<&str> = None;
let mut ignore_errors = false;
let mut dump_frames = false;
+ let mut force_dmx: Option<&str> = None;
while (cur_arg < args.len()) && args[cur_arg].starts_with('-') {
match args[cur_arg].as_str() {
@@ -145,6 +146,14 @@ fn main() {
}
vpfx = Some(args[cur_arg].clone());
},
+ "-demuxer" => {
+ cur_arg += 1;
+ if cur_arg == args.len() {
+ println!("name missing");
+ return;
+ }
+ force_dmx = Some(&args[cur_arg]);
+ },
"-ignerr" => { ignore_errors = true; },
"-dumpfrm" => { dump_frames = true; },
_ => { println!("unknown option {}", args[cur_arg]); return; },
@@ -179,7 +188,7 @@ fn main() {
}
let mut br = ByteReader::new(nfr.as_mut());
let full_reg = FullRegister::new();
- let mut demuxer = DemuxerObject::create(&mut br, &full_reg, name, is_raw);
+ let mut demuxer = DemuxerObject::create(&mut br, &full_reg, name, force_dmx, is_raw);
if demuxer.is_none() {
println!("No demuxer found!");
return;