test(engine): cover h265 NVENC in preset-mapping regression tests (#443)

hevc_nvenc uses the same p1..p7 preset vocabulary as h264_nvenc, so the
mapping in `mapPresetForGpuEncoder` applies to both codecs. The initial
regression suite only covered `codec: "h264"`, which left a gap: a
future refactor that split the H.264 and H.265 NVENC paths could
silently regress one codec without any test catching it.

Add three-case loops (ultrafast → p1, medium → p4, veryslow → p7) under
`codec: "h265"` to both `buildEncoderArgs` and `buildStreamingArgs`
test blocks. Each case also asserts that `-c:v hevc_nvenc` is selected
so the test fails loudly if the codec plumbing is broken, not just the
preset translation.

Follow-up to #442 per review comment from @jrusso1020.

Co-authored-by: roi32 <75878108+roi32@users.noreply.github.com>
This commit is contained in:
roiizchak
2026-04-23 09:20:44 -07:00
committed by GitHub
co-authored by roi32
parent 3b8de7a5eb
commit c11a332ef8
2 changed files with 38 additions and 0 deletions
@@ -191,6 +191,24 @@ describe("buildStreamingArgs", () => {
expect(presetArg(args)).toBe("p4");
});
// Same mapping applies to hevc_nvenc: NVENC's preset vocabulary is
// codec-agnostic, so the helper must translate for H.265 too.
it("translates libx264 preset names to NVENC pN for h265 as well", () => {
for (const [libx264, nvencPreset] of [
["ultrafast", "p1"],
["medium", "p4"],
["veryslow", "p7"],
] as const) {
const args = buildStreamingArgs(
{ ...baseGpu, codec: "h265", preset: libx264 },
"/tmp/out.mp4",
"nvenc",
);
expect(args[args.indexOf("-c:v") + 1]).toBe("hevc_nvenc");
expect(presetArg(args)).toBe(nvencPreset);
}
});
it("rewrites QSV's unsupported ultrafast preset to veryfast", () => {
const args = buildStreamingArgs(baseGpu, "/tmp/out.mp4", "qsv");
expect(presetArg(args)).toBe("veryfast");