]> git.nihav.org Git - nihav-tool.git/commitdiff
add option for forcing demuxer
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 10 Dec 2022 08:47:40 +0000 (09:47 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 10 Dec 2022 08:47:40 +0000 (09:47 +0100)
src/demux.rs
src/main.rs

index 07862753433ae696796240477228aaa512febd8b..56659c76a4cb928b2cce4144b34c8753dfce0588 100644 (file)
@@ -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);
index 8280799a790bbc7b31af4a532eeee4369d6a1441..929ab6eddebf72a67680e7853c2a795a3ec463b8 100644 (file)
@@ -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;