Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/engine/src/services/chunkEncoder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,26 @@ describe("buildEncoderArgs GPU preset mapping", () => {
expect(presetArg(args)).toBe("p5");
});

// hevc_nvenc uses the same p1..p7 preset vocabulary as h264_nvenc, so the
// mapping must apply to both codecs. Locks in "H.264 and H.265 NVENC share
// the preset mapping" against a future refactor that might split the path.
it("translates libx264 preset names to NVENC p1..p7 for h265 as well", () => {
for (const [libx264, nvencPreset] of [
["ultrafast", "p1"],
["medium", "p4"],
["veryslow", "p7"],
] as const) {
const args = buildEncoderArgs(
{ ...baseOptions, codec: "h265", preset: libx264, quality: 23, useGpu: true },
inputArgs,
"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 = buildEncoderArgs(
{ ...baseOptions, codec: "h264", preset: "ultrafast", quality: 28, useGpu: true },
Expand Down
18 changes: 18 additions & 0 deletions packages/engine/src/services/streamingEncoder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Loading