Only do long probes of FFmpeg content with the examiner, not the decoder.
authorCarl Hetherington <cth@carlh.net>
Wed, 20 Nov 2013 16:45:26 +0000 (16:45 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 20 Nov 2013 16:45:26 +0000 (16:45 +0000)
src/lib/ffmpeg.cc
src/lib/ffmpeg.h
src/lib/ffmpeg_decoder.cc
src/lib/ffmpeg_examiner.cc

index e9c41ea184f76b4ccabab981b1a3cebb7463d501..dbafba0f03a8bfe8e741e3a2f7a08c3e95ec7b2d 100644 (file)
@@ -37,13 +37,14 @@ using boost::lexical_cast;
 
 boost::mutex FFmpeg::_mutex;
 
-FFmpeg::FFmpeg (boost::shared_ptr<const FFmpegContent> c)
+/** @param long_probe true to do a long probe of the file looking for streams */
+FFmpeg::FFmpeg (boost::shared_ptr<const FFmpegContent> c, bool long_probe)
        : _ffmpeg_content (c)
        , _format_context (0)
        , _frame (0)
        , _video_stream (-1)
 {
-       setup_general ();
+       setup_general (long_probe);
        setup_video ();
        setup_audio ();
 }
@@ -65,16 +66,18 @@ FFmpeg::~FFmpeg ()
 }
 
 void
-FFmpeg::setup_general ()
+FFmpeg::setup_general (bool long_probe)
 {
        av_register_all ();
 
        AVDictionary* options = 0;
-       /* These durations are in microseconds, and represent how far into the content file
-          we will look for streams.
-       */
-       av_dict_set (&options, "analyzeduration", lexical_cast<string> (5 * 60 * 1e6).c_str(), 0);
-       av_dict_set (&options, "probesize", lexical_cast<string> (5 * 60 * 1e6).c_str(), 0);
+       if (long_probe) {
+               /* These durations are in microseconds, and represent how far into the content file
+                  we will look for streams.
+               */
+               av_dict_set (&options, "analyzeduration", lexical_cast<string> (5 * 60 * 1e6).c_str(), 0);
+               av_dict_set (&options, "probesize", lexical_cast<string> (5 * 60 * 1e6).c_str(), 0);
+       }
        
        if (avformat_open_input (&_format_context, _ffmpeg_content->path().string().c_str(), 0, &options) < 0) {
                throw OpenFileError (_ffmpeg_content->path().string ());
index 4d1a45da3b9c866c48d6757523bfb4d18acf364d..d5f4db2916c67e45fb014bb676397579a1cb8ef4 100644 (file)
@@ -41,7 +41,7 @@ class FFmpegContent;
 class FFmpeg
 {
 public:
-       FFmpeg (boost::shared_ptr<const FFmpegContent>);
+       FFmpeg (boost::shared_ptr<const FFmpegContent>, bool);
        virtual ~FFmpeg ();
 
        boost::shared_ptr<const FFmpegContent> ffmpeg_content () const {
@@ -67,7 +67,7 @@ protected:
        static boost::mutex _mutex;
 
 private:
-       void setup_general ();
+       void setup_general (bool);
        void setup_video ();
        void setup_audio ();
 };
index 19b99df90748c071bdc43db06ad4b19e23fb2e6d..be32475377da2c851647bc4ea8f247218c9d24f5 100644 (file)
@@ -63,7 +63,7 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegC
        , VideoDecoder (f, c)
        , AudioDecoder (f, c)
        , SubtitleDecoder (f)
-       , FFmpeg (c)
+       , FFmpeg (c, false)
        , _subtitle_codec_context (0)
        , _subtitle_codec (0)
        , _decode_video (video)
index 215c5e7582883069a2e887a905adf05e4f533dea..4d10aabbb85daf819f127a6946888446e56121ec 100644 (file)
@@ -32,7 +32,7 @@ using boost::shared_ptr;
 using boost::optional;
 
 FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c)
-       : FFmpeg (c)
+       : FFmpeg (c, true)
 {
        /* Find audio and subtitle streams */