From 48e56e1c8b9343ae84ddcda8bab795f763d2d544 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 18 Feb 2016 13:52:41 +0000 Subject: Fix crash when FFmpeg doesn't recognise a file's pixel format. --- src/lib/ffmpeg_examiner.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index dacc652bb..29cc69063 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -353,7 +353,13 @@ FFmpegExaminer::stream_name (AVStream* s) const int FFmpegExaminer::bits_per_pixel () const { - return av_get_bits_per_pixel (av_pix_fmt_desc_get (video_codec_context()->pix_fmt)); + if (video_codec_context()->pix_fmt == -1) { + throw DecodeError (_("Could not find pixel format for video.")); + } + + AVPixFmtDescriptor const * d = av_pix_fmt_desc_get (video_codec_context()->pix_fmt); + DCPOMATIC_ASSERT (d); + return av_get_bits_per_pixel (d); } bool -- cgit v1.2.3