mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-26 15:55:35 +00:00
fix(export): scale mp4 bitrate with frame rate
This commit is contained in:
@@ -15,6 +15,28 @@ describe("export bitrate policy", () => {
|
||||
).toBe(27_000_000);
|
||||
});
|
||||
|
||||
it("raises high-resolution 60fps source-quality exports above the 30fps budget", () => {
|
||||
const sharedOptions = {
|
||||
width: 2560,
|
||||
height: 1440,
|
||||
quality: "source" as const,
|
||||
encodingMode: "quality" as const,
|
||||
};
|
||||
|
||||
const thirtyFpsBitrate = getMp4ExportBitrate({
|
||||
...sharedOptions,
|
||||
frameRate: 30,
|
||||
});
|
||||
const sixtyFpsBitrate = getMp4ExportBitrate({
|
||||
...sharedOptions,
|
||||
frameRate: 60,
|
||||
});
|
||||
|
||||
expect(thirtyFpsBitrate).toBe(45_000_000);
|
||||
expect(sixtyFpsBitrate).toBeGreaterThan(thirtyFpsBitrate);
|
||||
expect(sixtyFpsBitrate).toBe(63_639_610);
|
||||
});
|
||||
|
||||
it("keeps modern native static-layout source exports high enough for screen text", () => {
|
||||
expect(
|
||||
getMp4ExportBitrate({
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { ExportEncodingMode, ExportMp4FrameRate, ExportQuality } from "./ty
|
||||
|
||||
const MIN_MP4_BITRATE = 2_000_000;
|
||||
const REFERENCE_PIXEL_RATE = 1920 * 1080 * 30;
|
||||
const REFERENCE_FRAME_RATE = 30;
|
||||
|
||||
export function getEncodingModeBitrateMultiplier(encodingMode: ExportEncodingMode): number {
|
||||
switch (encodingMode) {
|
||||
@@ -41,6 +42,10 @@ function getBaseMp4ExportBitrate(width: number, height: number, quality: ExportQ
|
||||
return 30_000_000;
|
||||
}
|
||||
|
||||
function getFrameRateBitrateMultiplier(frameRate: ExportMp4FrameRate): number {
|
||||
return Math.sqrt(Math.max(1, frameRate / REFERENCE_FRAME_RATE));
|
||||
}
|
||||
|
||||
function getModernNativeStaticLayoutBitrateCap(
|
||||
width: number,
|
||||
height: number,
|
||||
@@ -87,6 +92,7 @@ export function getMp4ExportBitrate(options: {
|
||||
}): number {
|
||||
const requestedBitrate = Math.round(
|
||||
getBaseMp4ExportBitrate(options.width, options.height, options.quality) *
|
||||
getFrameRateBitrateMultiplier(options.frameRate) *
|
||||
getEncodingModeBitrateMultiplier(options.encodingMode),
|
||||
);
|
||||
const nativeStaticLayoutBitrate =
|
||||
|
||||
Reference in New Issue
Block a user