]> git.sesse.net Git - nageru/blobdiff - ffmpeg_capture.cpp
Change from RGBA to BGRA; slightly more Intel GPU-friendly, and Caspar uses that...
[nageru] / ffmpeg_capture.cpp
index 6e672d9d837e1ec6145dda12abc4dcd27eb22b1a..ab35c5c5ef1c5f18e66f338fa1cad20fef860a9d 100644 (file)
@@ -297,7 +297,7 @@ bool FFmpegCapture::play_video(const string &pathname)
                if (sws_ctx == nullptr || sws_last_width != frame->width || sws_last_height != frame->height) {
                        sws_ctx.reset(
                                sws_getContext(frame->width, frame->height, (AVPixelFormat)frame->format,
-                                       width, height, AV_PIX_FMT_RGBA,
+                                       width, height, AV_PIX_FMT_BGRA,
                                        SWS_BICUBIC, nullptr, nullptr, nullptr));
                        sws_last_width = frame->width;
                        sws_last_height = frame->height;
@@ -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;