From 038773e79eff9e02b82e58e2ad31fd17bbb6e188 Mon Sep 17 00:00:00 2001 From: JakeBreath Date: Thu, 17 Sep 2026 20:45:47 -0500 Subject: [PATCH] Use bitrate-based quality presets for video encoding Qualitative presets made Mediabunny use quantizer (CRF-like) encoding, but hardware H.264 encoders commonly ignore the per-frame quantizer and fall back to a very low default bitrate, producing files far smaller than the preset implies. Passing preferBitrate makes the preset map to an explicit bitrate so hardware and software paths agree. --- frontend/src/features/optimize/video.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/features/optimize/video.ts b/frontend/src/features/optimize/video.ts index d1587f5..558a57f 100644 --- a/frontend/src/features/optimize/video.ts +++ b/frontend/src/features/optimize/video.ts @@ -156,7 +156,13 @@ export async function optimizeVideo( const outputWidth = even( Math.round(sourceWidth * (outputHeight / sourceHeight)), ); - const quality = new Quality(options.qualityLevel); + // Prefer bitrate-based encoding: hardware encoders often ignore the + // per-frame quantizer that qualitative presets would otherwise use, which + // made results inconsistent (and sometimes tiny). + const quality = new Quality({ + quality: options.qualityLevel, + preferBitrate: true, + }); const candidates: VideoCodec[] = options.codec === "auto" ? CODEC_CANDIDATES[container] : [options.codec]; const preferences: ("prefer-hardware" | "no-preference")[] =