Make terminate_threads() less likely to leave _threads containing invalid pointers.
[dcpomatic.git] / src / lib / ffmpeg.cc
index 8a0dcb5930afaad11cff0706d9ab3df7c199b814..f26d1d2cf224530582f709482840a2fb6840be39 100644 (file)
@@ -128,7 +128,7 @@ FFmpeg::setup_general ()
 
        int e = avformat_open_input (&_format_context, 0, 0, &options);
        if (e < 0) {
-               throw OpenFileError (_ffmpeg_content->path(0).string(), e, true);
+               throw OpenFileError (_ffmpeg_content->path(0).string(), e, OpenFileError::READ);
        }
 
        if (avformat_find_stream_info (_format_context, 0) < 0) {
@@ -159,6 +159,11 @@ FFmpeg::setup_general ()
                _video_stream = video_stream_undefined_frame_rate.get();
        }
 
+       /* Ignore video streams with crazy frame rates.  These are usually things like album art on MP3s. */
+       if (_video_stream && av_q2d(av_guess_frame_rate(_format_context, _format_context->streams[_video_stream.get()], 0)) > 1000) {
+               _video_stream = optional<int>();
+       }
+
        /* Hack: if the AVStreams have duplicate IDs, replace them with our
           own.  We use the IDs so that we can cope with VOBs, in which streams
           move about in index but remain with the same ID in different