From d82fc3dec1001dc5fd83e30c4e75e21ff8c69e59 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 24 Dec 2024 18:54:10 -0800 Subject: [PATCH] FFmpeg: Fix failing to record videos with CRF video (fixes #3368) --- CHANGES | 1 + src/feature/ffmpeg/ffmpeg-encoder.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 847865d26..62f51060c 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,7 @@ Emulation fixes: Other fixes: - Core: Fix inconsistencies with setting game-specific overrides (fixes mgba.io/i/2963) - Debugger: Fix writing to specific segment in command-line debugger + - FFmpeg: Fix failing to record videos with CRF video (fixes mgba.io/i/3368) - GB Serialize: Prevent loading invalid states where LY >= 144 in modes other than 1 - GBA: Fix getting game info for multiboot ROMs - GBA Core: Fix booting into BIOS when skip BIOS is enabled diff --git a/src/feature/ffmpeg/ffmpeg-encoder.c b/src/feature/ffmpeg/ffmpeg-encoder.c index 6202e0fcd..e83aa680c 100644 --- a/src/feature/ffmpeg/ffmpeg-encoder.c +++ b/src/feature/ffmpeg/ffmpeg-encoder.c @@ -384,7 +384,9 @@ bool FFmpegEncoderOpen(struct FFmpegEncoder* encoder, const char* outfile) { encoder->videoStream = avformat_new_stream(encoder->context, vcodec); encoder->video = encoder->videoStream->codec; #endif - encoder->video->bit_rate = encoder->videoBitrate; + if (encoder->videoBitrate >= 0) { + encoder->video->bit_rate = encoder->videoBitrate; + } encoder->video->width = encoder->width; encoder->video->height = encoder->height; encoder->video->time_base = (AVRational) { encoder->frameCycles * encoder->frameskip, encoder->cycles };