From 1e32fcaebedaab37c2fcfb4ff9cab0bd7bb41fc3 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Wed, 28 Jun 2023 00:40:11 -0500 Subject: [PATCH] GS:Capture: Prefer h264 as the default codec FFmpeg's default is mpeg4 for a number of containers if it was compiled without x264 --- pcsx2/GS/GSCapture.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pcsx2/GS/GSCapture.cpp b/pcsx2/GS/GSCapture.cpp index b4a94ff525..336c6c1904 100644 --- a/pcsx2/GS/GSCapture.cpp +++ b/pcsx2/GS/GSCapture.cpp @@ -409,8 +409,14 @@ bool GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float fmt::format("Video codec {} not found, using default.", GSConfig.VideoCaptureCodec), Host::OSD_ERROR_DURATION); } } + + // FFmpeg decides whether mp4, mkv, etc should use h264 or mpeg4 as their default codec by whether x264 was enabled + // But there's a lot of other h264 encoders (e.g. hardware encoders) we may want to use instead + if (!vcodec && wrap_avformat_query_codec(output_format, AV_CODEC_ID_H264, FF_COMPLIANCE_NORMAL)) + vcodec = wrap_avcodec_find_encoder(AV_CODEC_ID_H264); if (!vcodec) vcodec = wrap_avcodec_find_encoder(output_format->video_codec); + if (!vcodec) { Host::AddIconOSDMessage("GSCaptureError", ICON_FA_CAMERA, "Failed to find video encoder.", Host::OSD_ERROR_DURATION);