Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(media-server): default nvenc to p1 at crf+8 without lookahead to match x264 size and vmaf

Richie McIlroy61bfdc9f5a08
diff --git a/apps/media-server/src/__tests__/lib/nvenc-encoder.test.ts b/apps/media-server/src/__tests__/lib/nvenc-encoder.test.ts
index b698a77bd..b1fdbb827 100644
--- a/apps/media-server/src/__tests__/lib/nvenc-encoder.test.ts
+++ b/apps/media-server/src/__tests__/lib/nvenc-encoder.test.ts
@@ -28,9 +28,9 @@ import {
const enabled = { CAP_MEDIA_VIDEO_ENCODER: "nvenc" };
const defaults: NvencOptions = {
- preset: "p5",
- cqOffset: 2,
- lookahead: 20,
+ preset: "p1",
+ cqOffset: 8,
+ lookahead: 0,
spatialAq: true,
temporalAq: false,
gpuDecodeCodecs: ["hevc", "av1"],
@@ -46,19 +46,17 @@ const nvencVideoArgs = [
"-c:v",
"h264_nvenc",
"-preset",
- "p5",
+ "p1",
"-tune",
"hq",
"-rc",
"vbr",
"-cq",
- "25",
+ "31",
"-b:v",
"0",
"-spatial-aq",
"1",
- "-rc-lookahead",
- "20",
"-profile:v",
"high",
"-g",
@@ -141,7 +139,7 @@ describe("nvenc encoder selection", () => {
});
});
- test("uses p5, cq = crf + 2, lookahead 20 and spatial AQ by default", () => {
+ test("uses p1, cq = crf + 8, no lookahead and spatial AQ by default", () => {
expect(nvencOptionsFromEnv(enabled)).toEqual(defaults);
});
@@ -204,13 +202,13 @@ describe("nvenc encoder selection", () => {
"-c:v",
"h264_nvenc",
"-preset",
- "p5",
+ "p1",
"-tune",
"hq",
"-rc",
"vbr",
"-cq",
- "20",
+ "26",
"-b:v",
"0",
"-temporal-aq",
@@ -562,19 +560,17 @@ describe("edit re-encode args", () => {
"-c:v",
"h264_nvenc",
"-preset",
- "p5",
+ "p1",
"-tune",
"hq",
"-rc",
"vbr",
"-cq",
- "20",
+ "26",
"-b:v",
"0",
"-spatial-aq",
"1",
- "-rc-lookahead",
- "20",
"-profile:v",
"high",
"-g",
diff --git a/apps/media-server/src/lib/nvenc-encoder.ts b/apps/media-server/src/lib/nvenc-encoder.ts
index d79432aec..a6d016599 100644
--- a/apps/media-server/src/lib/nvenc-encoder.ts
+++ b/apps/media-server/src/lib/nvenc-encoder.ts
@@ -1,6 +1,6 @@
-const DEFAULT_PRESET = "p5";
-const DEFAULT_CQ_OFFSET = 2;
-const DEFAULT_LOOKAHEAD = 20;
+const DEFAULT_PRESET = "p1";
+const DEFAULT_CQ_OFFSET = 8;
+const DEFAULT_LOOKAHEAD = 0;
const MAX_LOOKAHEAD = 32;
const GOP_LENGTH = "250";
const NVENC_PRESETS = new Set(["p1", "p2", "p3", "p4", "p5", "p6", "p7"]);