]> git.sesse.net Git - nageru/commitdiff
Don't crash on invalid frame rates from FFmpeg.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 20 Apr 2017 22:16:28 +0000 (00:16 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 20 Apr 2017 22:16:28 +0000 (00:16 +0200)
ffmpeg_capture.cpp

index 6e672d9d837e1ec6145dda12abc4dcd27eb22b1a..2f9c6fdc1be3bb096c0a22dd760ac11084b02cd6 100644 (file)
@@ -313,6 +313,11 @@ bool FFmpegCapture::play_video(const string &pathname)
                video_format.stride = width * 4;
                video_format.frame_rate_nom = video_timebase.den;
                video_format.frame_rate_den = av_frame_get_pkt_duration(frame.get()) * video_timebase.num;
+               if (video_format.frame_rate_nom == 0 || video_format.frame_rate_den == 0) {
+                       // Invalid frame rate.
+                       video_format.frame_rate_nom = 60;
+                       video_format.frame_rate_den = 1;
+               }
                video_format.has_signal = true;
                video_format.is_connected = true;