From: Kostya Shishkov Date: Sat, 10 Dec 2022 08:47:40 +0000 (+0100) Subject: add option for forcing demuxer X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=8a8f6e5c8847945e274c5d7e2c6a51c027c19c35;p=nihav-tool.git add option for forcing demuxer --- 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;