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.
This commit is contained in:
lummax 2015-09-11 14:43:38 +02:00 committed by meh
parent a84b30b3f0
commit 71d23d0f92

View File

@ -100,13 +100,13 @@ fn main() {
let time_base = (1, 1000000);
let mut frame = frame::Audio::empty();
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();
let os = octx.stream(0).unwrap();
(os.index(), os.time_base())
};
for (stream, mut packet) in ictx.packets() {
if stream.index() == transcoder.stream {
packet.rescale_ts(stream.time_base(), time_base);
if transcoder.decoder.decode(&packet, &mut frame).unwrap() {