From 3462ea3fdac41b2d544bc9403edac0820d42e911 Mon Sep 17 00:00:00 2001 From: jpark37 Date: Tue, 24 Jan 2023 09:12:18 -0800 Subject: [PATCH] obs-ffmpeg: Tell FFmpeg that BGRA uses alpha Prevents alpha from getting dropped with custom encoders. --- plugins/obs-ffmpeg/obs-ffmpeg-output.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-output.c b/plugins/obs-ffmpeg/obs-ffmpeg-output.c index 3d5a5498d..9f3a807d0 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-output.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-output.c @@ -241,8 +241,10 @@ static bool create_video_stream(struct ffmpeg_data *data) closest_format = data->config.format; if (data->vcodec->pix_fmts) { + const int has_alpha = closest_format == AV_PIX_FMT_BGRA; closest_format = avcodec_find_best_pix_fmt_of_list( - data->vcodec->pix_fmts, data->config.format, 0, NULL); + data->vcodec->pix_fmts, closest_format, has_alpha, + NULL); } #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101)