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;
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;