summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-08-10 15:48:45 +0100
committerCarl Hetherington <cth@carlh.net>2012-08-10 15:48:45 +0100
commit5a7a576c41389aa7daebfc37d3d8b0763e96263b (patch)
tree4c12d2c0f541789a6586f9123f03f4793fdc02ea /src/lib/ffmpeg_decoder.cc
parent8c4ea6d32a87453cb34ad732a026fa624bfe0f6b (diff)
Untested fixes for files without audio.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
-rw-r--r--src/lib/ffmpeg_decoder.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index d2a10be1f..c12e6728d 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -107,9 +107,6 @@ FFmpegDecoder::setup_general ()
if (_video_stream < 0) {
throw DecodeError ("could not find video stream");
}
- if (_audio_stream < 0) {
- throw DecodeError ("could not find audio stream");
- }
_frame = avcodec_alloc_frame ();
if (_frame == 0) {
@@ -135,6 +132,10 @@ FFmpegDecoder::setup_video ()
void
FFmpegDecoder::setup_audio ()
{
+ if (_audio_stream < 0) {
+ return;
+ }
+
_audio_codec_context = _format_context->streams[_audio_stream]->codec;
_audio_codec = avcodec_find_decoder (_audio_codec_context->codec_id);
@@ -162,7 +163,7 @@ FFmpegDecoder::do_pass ()
process_video (_frame);
}
- } else if (_packet.stream_index == _audio_stream && _opt->decode_audio) {
+ } else if (_audio_stream >= 0 && _packet.stream_index == _audio_stream && _opt->decode_audio) {
avcodec_get_frame_defaults (_frame);
@@ -216,12 +217,20 @@ FFmpegDecoder::audio_sample_rate () const
AVSampleFormat
FFmpegDecoder::audio_sample_format () const
{
+ if (_audio_codec_context == 0) {
+ return (AVSampleFormat) 0;
+ }
+
return _audio_codec_context->sample_fmt;
}
int64_t
FFmpegDecoder::audio_channel_layout () const
{
+ if (_audio_codec_context == 0) {
+ return 0;
+ }
+
return _audio_codec_context->channel_layout;
}