add PNM image sequence as possible input source
[nihav-encoder.git] / src / main.rs
index e033dfd1040cd3d7b5eb965b351e1c8d926ce309..97be1e2ea36367b6b833a1b61f5134cc5a5619da 100644 (file)
@@ -23,6 +23,8 @@ use crate::demux::*;
 mod null;
 mod acvt;
 use crate::acvt::*;
+mod imgseq;
+use crate::imgseq::*;
 
 const SND_NO_FORMAT: NASoniton = NASoniton { bits: 0, be: false, packed: false, planar: false, float: false, signed: false };
 
@@ -1068,6 +1070,20 @@ fn main() {
         return;
     }
 
+    if let Some("imgseq") = transcoder.input_fmt.as_deref() {
+        let mut isdc = ImgSeqDemuxerCreator::new(transcoder.input_name.as_str());
+        parse_and_apply_options!(isdc, &transcoder.demux_opts, "input");
+        let isd = if let Ok(ctx) = isdc.open() {
+                ctx
+            } else {
+                println!("failed to create image sequence demuxer!");
+                return;
+            };
+        let mut dmx = DemuxerObject::create_imgseq(isd);
+        transcode(transcoder, full_reg, &mut dmx);
+        return;
+    }
+
     let res = File::open(transcoder.input_name.as_str());
     if res.is_err() {
         println!("error opening input");
@@ -1097,10 +1113,14 @@ fn main() {
         println!("cannot find demuxer for '{}'", transcoder.input_name.as_str());
         return;
     }
+    parse_and_apply_options!(dmx, &transcoder.demux_opts, "input");
+    transcode(transcoder, full_reg, &mut dmx);
+}
+
+fn transcode(mut transcoder: Transcoder, full_reg: FullRegister, dmx: &mut DemuxerObject) {
     let duration = dmx.get_duration();
     let duration_string = if duration != 0 { format_time(duration) } else { String::new() };
 
-    parse_and_apply_options!(dmx, &transcoder.demux_opts, "input");
     for i in 0..dmx.get_num_streams() {
         let s = dmx.get_stream(i).unwrap();
         let info = s.get_info();