domyd / mlp

A Dolby TrueHD demuxer and utility tool, with a focus on accurate and correct TrueHD demuxing.
Apache License 2.0
64 stars 2 forks source link

Panic when playlist segment contains no TrueHD stream #15

Closed nekno closed 2 years ago

nekno commented 2 years ago

A Rust panic is encountered when using the select-stream branch to select the stream from a playlist that includes a segment without a TrueHD stream:

>mlp demux playlist C:\disk\BDMV\PLAYLIST\00020.mpls --output "C:\disk\mlp-6ch.thd" --stream 2
15:57:28 [INFO] Stream: index: 2, id: 0x1101, language: eng, 48000 Hz, 6 ch
15:57:28 [INFO] Stream: index: 4, id: 0x1102, language: eng, 48000 Hz, 8 ch
15:57:28 [INFO] Processing file 1/2 ('C:\disk\BDMV\STREAM\00007.m2ts') ...
15:58:18 [INFO] Processing file 2/2 ('C:\disk\BDMV\STREAM\00000.m2ts') ...              s
15:58:18 [INFO] Checking segment file gap.
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src\libav\demux.rs:219:22
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\core\src\panicking.rs:143
   2: core::panicking::panic
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\core\src\panicking.rs:48
   3: mlp::libav::demux::demux_thd
   4: alloc::alloc::box_free
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Line 219 is this statement:

let decoded_head_frame = streams
  .iter()
  .find(|&s| s.codec.id == ffmpeg4_ffi::sys::AVCodecID_AV_CODEC_ID_TRUEHD)
  .unwrap();