handle decoding errors a bit better
authorKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 24 Mar 2020 13:47:47 +0000 (14:47 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 24 Mar 2020 13:47:47 +0000 (14:47 +0100)
src/main.rs

index 1541b18..71ccda6 100644 (file)
@@ -219,14 +219,24 @@ panic!("decoder {} not found", info.get_name());
         let sr = sids.iter().position(|x| *x == streamno);
         let idx = sr.unwrap();
         if let Some((ref mut dsupp, ref mut dec)) = decs[idx] {
-            let frm = dec.decode(dsupp, &pkt).unwrap();
-            if !noout {
-                match writers[idx] {
-                    Outputter::Video(ref mut wr) => { wr.output_frame(&pkt, frm); },
-                    Outputter::Audio(ref mut wr) => { wr.output_frame(&pkt, frm); },
-                    _ => {},
-                };
-            }
+            match dec.decode(dsupp, &pkt) {
+                Ok(frm) => {
+                    if !noout {
+                        match writers[idx] {
+                            Outputter::Video(ref mut wr) => { wr.output_frame(&pkt, frm); },
+                            Outputter::Audio(ref mut wr) => { wr.output_frame(&pkt, frm); },
+                            _ => {},
+                        };
+                    }
+                },
+                Err(DecoderError::MissingReference) if seek_time > 0 => {
+                    println!("ignoring missing ref");
+                },
+                Err(reason) => {
+                    println!("error decoding frame {:?}", reason);
+                    break;
+                },
+            };
         }
         if pkt.get_pts() != None && lastpts.is_some() && pkt.get_pts() >= lastpts { break; }
     }