From 71d23d0f92ee7e66d4ec7f9672c311f787c863f5 Mon Sep 17 00:00:00 2001 From: lummax Date: Fri, 11 Sep 2015 14:43:38 +0200 Subject: [PATCH] examples/transcode-audio: fix on input with multiple streams On input files with muliple streams the best audio streams gets transcoded. If this stream happens to have an `index > 0` the transcoding crashes as no associated output stream is available. This commit fixes this by using the first (and only) output stream. --- examples/transcode-audio.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/transcode-audio.rs b/examples/transcode-audio.rs index 4bb9c39..c7e3344 100644 --- a/examples/transcode-audio.rs +++ b/examples/transcode-audio.rs @@ -100,13 +100,13 @@ fn main() { let time_base = (1, 1000000); let mut frame = frame::Audio::empty(); + let (os_index, os_time_base) = { + let os = octx.stream(0).unwrap(); + (os.index(), os.time_base()) + }; + for (stream, mut packet) in ictx.packets() { if stream.index() == transcoder.stream { - let (os_index, os_time_base) = { - let os = octx.stream(stream.index()).unwrap(); - (os.index(), os.time_base()) - }; - packet.rescale_ts(stream.time_base(), time_base); if transcoder.decoder.decode(&packet, &mut frame).unwrap() {