diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-20 01:03:56 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-20 01:03:56 +0100 |
| commit | 521bb8570ae37e3710cf0d9cdb78e19bf1ed9463 (patch) | |
| tree | 3ae73a81c8370c62cb450e1d246aa895297e88d9 /src/lib/ffmpeg_decoder.cc | |
| parent | d7d1a6b8d97390e57ce8d2442d90d25f97d8b562 (diff) | |
Speculative fix for failure to pick up correct audio / subtitle streams.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 554188343..4b0594add 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -106,6 +106,8 @@ FFmpegDecoder::setup_general () throw DecodeError ("could not find stream information"); } + /* Find video, audio and subtitle streams and choose the first of each */ + for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { if (_format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { _video_stream = i; @@ -122,6 +124,30 @@ FFmpegDecoder::setup_general () } } + /* Now override audio and subtitle streams with those from the Film, if it has any */ + + if (_fs->audio_stream() != -1) { + vector<Stream>::iterator i = _audio_streams.begin (); + while (i != _audio_streams.end() && i->id != _fs->audio_stream()) { + ++i; + } + + if (i != _audio_streams.end()) { + _audio_stream = _fs->audio_stream (); + } + } + + if (_fs->subtitle_stream() != -1) { + vector<Stream>::iterator i = _subtitle_streams.begin (); + while (i != _subtitle_streams.end() && i->id != _fs->subtitle_stream()) { + ++i; + } + + if (i != _subtitle_streams.end()) { + _subtitle_stream = _fs->subtitle_stream (); + } + } + if (_video_stream < 0) { throw DecodeError ("could not find video stream"); } |
