X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fffmpeg.cc;h=fa369dda429c9342c2b08eed7a4b74ee50a38c35;hb=cc27c2716f755305d67f1e1ba828ecf37f8405dd;hp=ec7ec452e37683bfe374a16589d56c49377df562;hpb=5f15ca0a1ba5344e46f837e8021acfc7e4a850c3;p=dcpomatic.git diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index ec7ec452e..fa369dda4 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -26,6 +26,7 @@ extern "C" { #include "ffmpeg.h" #include "ffmpeg_content.h" #include "ffmpeg_audio_stream.h" +#include "ffmpeg_subtitle_stream.h" #include "exceptions.h" #include "util.h" @@ -33,7 +34,6 @@ extern "C" { using std::string; using std::cout; -using std::stringstream; using boost::shared_ptr; using dcp::raw_convert; @@ -148,13 +148,13 @@ FFmpeg::setup_decoders () AVCodecContext* context = _format_context->streams[i]->codec; AVCodec* codec = avcodec_find_decoder (context->codec_id); - if (codec == 0) { - throw DecodeError (N_("could not find decoder")); - } - - if (avcodec_open2 (context, codec, 0) < 0) { - throw DecodeError (N_("could not open decoder")); + if (codec) { + if (avcodec_open2 (context, codec, 0) < 0) { + throw DecodeError (N_("could not open decoder")); + } } + + /* We are silently ignoring any failures to find suitable decoders here */ } } @@ -174,6 +174,16 @@ FFmpeg::audio_codec_context () const return _ffmpeg_content->audio_stream()->stream(_format_context)->codec; } +AVCodecContext * +FFmpeg::subtitle_codec_context () const +{ + if (!_ffmpeg_content->subtitle_stream ()) { + return 0; + } + + return _ffmpeg_content->subtitle_stream()->stream(_format_context)->codec; +} + int FFmpeg::avio_read (uint8_t* buffer, int const amount) {