From 8761fa1a2cc14f1e512c2e3b591e447942233649 Mon Sep 17 00:00:00 2001 From: Kurt Kartaltepe Date: Tue, 8 Sep 2020 21:22:24 -0700 Subject: [PATCH] obs-ffmpeg: fix crash with rawvideo Some codecs have no recommended pix_fmts so we must check that pix_fmts is not null before trying to find a good match. This just prays whatever OBS is configure for is a valid format when users choose these oddball codecs. When its not you should get a normal recording fail instead of a crash now. fixes #3031 --- plugins/obs-ffmpeg/obs-ffmpeg-output.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-output.c b/plugins/obs-ffmpeg/obs-ffmpeg-output.c index b04df3b7a..e5df0c6c2 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-output.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-output.c @@ -221,8 +221,11 @@ static bool create_video_stream(struct ffmpeg_data *data) data->config.video_encoder)) return false; - closest_format = avcodec_find_best_pix_fmt_of_list( - data->vcodec->pix_fmts, data->config.format, 0, NULL); + closest_format = data->config.format; + if (data->vcodec->pix_fmts) { + closest_format = avcodec_find_best_pix_fmt_of_list( + data->vcodec->pix_fmts, data->config.format, 0, NULL); + } #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101) context = avcodec_alloc_context3(data->vcodec);