mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-07 18:26:17 +00:00
test(render): add WebM regression test and getEncoderPreset unit tests
- New regression test `webm-transparency`: minimal transparent composition
rendered to WebM, validates VP9 codec and visual quality at 100
checkpoints against golden baseline
- Extend regression harness: `renderConfig.format` field ("mp4" | "webm"),
format-aware output paths and snapshot filenames
- Fix `extractMonoPcm16` to gracefully handle videos without audio
streams (WebM without audio was throwing instead of returning empty)
- Unit tests for `getEncoderPreset()`: VP9/yuva420p for WebM,
h264/yuv420p for MP4, preset mapping, quality preservation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { ENCODER_PRESETS } from "./chunkEncoder.js";
|
||||
import { ENCODER_PRESETS, getEncoderPreset } from "./chunkEncoder.js";
|
||||
|
||||
describe("ENCODER_PRESETS", () => {
|
||||
it("has draft, standard, and high presets", () => {
|
||||
@@ -25,3 +25,40 @@ describe("ENCODER_PRESETS", () => {
|
||||
expect(ENCODER_PRESETS.standard.quality).toBeLessThan(ENCODER_PRESETS.draft.quality);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getEncoderPreset", () => {
|
||||
it("returns h264 with yuv420p for mp4 format", () => {
|
||||
const preset = getEncoderPreset("standard", "mp4");
|
||||
expect(preset.codec).toBe("h264");
|
||||
expect(preset.pixelFormat).toBe("yuv420p");
|
||||
});
|
||||
|
||||
it("returns vp9 with yuva420p for webm format", () => {
|
||||
const preset = getEncoderPreset("standard", "webm");
|
||||
expect(preset.codec).toBe("vp9");
|
||||
expect(preset.pixelFormat).toBe("yuva420p");
|
||||
});
|
||||
|
||||
it("maps draft ultrafast to vp9 realtime deadline", () => {
|
||||
const preset = getEncoderPreset("draft", "webm");
|
||||
expect(preset.preset).toBe("realtime");
|
||||
expect(preset.codec).toBe("vp9");
|
||||
});
|
||||
|
||||
it("maps standard/high to vp9 good deadline", () => {
|
||||
expect(getEncoderPreset("standard", "webm").preset).toBe("good");
|
||||
expect(getEncoderPreset("high", "webm").preset).toBe("good");
|
||||
});
|
||||
|
||||
it("preserves quality values across formats", () => {
|
||||
for (const q of ["draft", "standard", "high"] as const) {
|
||||
expect(getEncoderPreset(q, "webm").quality).toBe(ENCODER_PRESETS[q].quality);
|
||||
}
|
||||
});
|
||||
|
||||
it("defaults to mp4 when format is omitted", () => {
|
||||
const preset = getEncoderPreset("standard");
|
||||
expect(preset.codec).toBe("h264");
|
||||
expect(preset.pixelFormat).toBe("yuv420p");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user