From b0a1581f2fca90bb7b9396386c1cb511011474a9 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 21 Apr 2017 00:16:28 +0200 Subject: [PATCH] Don't crash on invalid frame rates from FFmpeg. --- ffmpeg_capture.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ffmpeg_capture.cpp b/ffmpeg_capture.cpp index 6e672d9..2f9c6fd 100644 --- a/ffmpeg_capture.cpp +++ b/ffmpeg_capture.cpp @@ -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; -- 2.39.2