@gentbajko/slopify 4.3.5 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/edge/http/projects.js +4 -1
  2. package/dist/extension/slopify-studio-chrome.zip +0 -0
  3. package/dist/extension/slopify-studio-firefox.zip +0 -0
  4. package/dist/main.js +12 -3
  5. package/dist/patch-notes/4.4.0.md +37 -0
  6. package/dist/patch-notes/4.5.0.md +20 -0
  7. package/dist/patch-notes/index.json +12 -0
  8. package/dist/slices/admission/schema.js +3 -1
  9. package/dist/slices/rebuild/recipe-edit.js +8 -1
  10. package/dist/slices/rebuild/runtime-export.js +4 -3
  11. package/dist/slices/revisions/view.js +19 -8
  12. package/dist/slices/shorts/captions.js +2 -1
  13. package/dist/slices/storage/named-ids.js +46 -0
  14. package/dist/slices/storage/trim.js +24 -12
  15. package/dist/slices/subtitles/captions.js +2 -1
  16. package/dist/slices/video/cards.js +2 -0
  17. package/dist/slices/video/clip-cache.js +15 -7
  18. package/dist/slices/video/clip-captions.js +120 -0
  19. package/dist/slices/video/colour.js +22 -0
  20. package/dist/slices/video/edit-settings.js +17 -0
  21. package/dist/slices/video/encoder-probe.js +124 -0
  22. package/dist/slices/video/encoding.js +157 -92
  23. package/dist/slices/video/ffmpeg.js +64 -73
  24. package/dist/slices/video/look.js +23 -9
  25. package/dist/slices/video/move.js +89 -0
  26. package/dist/slices/video/pool.js +6 -5
  27. package/dist/slices/video/slideshow.js +137 -28
  28. package/dist/slices/video/still-sizes.js +37 -0
  29. package/dist/tutorials/Create-Video-and-Style.md +13 -0
  30. package/dist/tutorials/Settings-Reference.md +4 -2
  31. package/dist/tutorials/Video-Editing.md +4 -0
  32. package/dist/web/assets/index-hN_yzSRs.js +460 -0
  33. package/dist/web/index.html +1 -1
  34. package/package.json +1 -1
  35. package/dist/web/assets/index-Bvtq2QTE.js +0 -460
@@ -17,6 +17,12 @@ export const colorGrades = ["none", "warm", "cold", "desaturated", "sepia"];
17
17
  // Drawn procedurally by ffmpeg's own filters (`look.ts`); no third-party footage.
18
18
  export const atmospheres = ["none", "embers", "dust", "fog"];
19
19
  export const animateModes = ["off", "chapters", "every"];
20
+ // The finished video's codec. How it is encoded (processor or NVIDIA card) is the computer's
21
+ // choice (`encoding.ts`); this is the project's, since it changes the file. The stored values
22
+ // are the explicit choices; no value at all is Automatic: AV1 on an NVIDIA card that can
23
+ // encode it, else H.264 exactly as before.
24
+ export const videoCodecs = ["h264", "hevc", "av1"];
25
+ export const videoCodecChoices = ["auto", ...videoCodecs];
20
26
  export const legacyVideoEdit = {
21
27
  cuts: "interval",
22
28
  transition: "cut",
@@ -86,6 +92,16 @@ export const animateModeLabels = {
86
92
  chapters: "Chapter openers",
87
93
  every: "Every Nth image",
88
94
  };
95
+ export const videoCodecLabels = {
96
+ auto: "Automatic (AV1 on the graphics card, else H.264)",
97
+ h264: "H.264",
98
+ hevc: "HEVC",
99
+ av1: "AV1",
100
+ };
101
+ export const videoCodecHelp = "Automatic uses AV1 on an NVIDIA card that can encode it, else H.264. H.264 works everywhere. HEVC and AV1 make about half to a third of the file for the same picture; AV1 on the processor needs an ffmpeg with SVT-AV1 and renders slower.";
102
+ export function videoCodecOf(config) {
103
+ return config.videoEdit?.codec ?? "auto";
104
+ }
89
105
  // The settings a project renders with: its own, or today's behaviour when it has none.
90
106
  export function videoEditOf(config) {
91
107
  return config.videoEdit ?? legacyVideoEdit;
@@ -186,6 +202,7 @@ export function videoEditRows(edit) {
186
202
  ? animateModeLabels.off
187
203
  : `${edit.animate === "every" ? `Every ${nth(edit.animateEvery)} image` : animateModeLabels.chapters}${edit.animateModel.trim() === "" ? "" : ` · ${edit.animateModel}`}`,
188
204
  ],
205
+ ["Video codec", videoCodecLabels[edit.codec ?? "auto"]],
189
206
  ];
190
207
  }
191
208
  // Which images of the slideshow order (0-based) are animated: every Nth from the first, or
@@ -0,0 +1,124 @@
1
+ import { errorText } from "../../kernel/errors.js";
2
+ import { videoCodecLabels } from "./edit-settings.js";
3
+ import { codecArgs, noNvenc, noSvtAv1 } from "./encoding.js";
4
+ export const failedNvenc = "No working NVIDIA graphics card was found on this computer.";
5
+ const failedSvtAv1 = "No working ffmpeg with SVT-AV1 (libsvtav1) was found on this computer.";
6
+ // The renders' own settings on a tiny picture: a driver or card that refuses any of them fails
7
+ // here rather than in a render. NVENC refuses anything under about 145 pixels across.
8
+ function testArgs(encode) {
9
+ return [
10
+ "-hide_banner",
11
+ "-nostdin",
12
+ "-loglevel",
13
+ "error",
14
+ "-f",
15
+ "lavfi",
16
+ "-i",
17
+ "color=c=black:s=256x256:r=30:d=0.1",
18
+ "-frames:v",
19
+ "1",
20
+ ...codecArgs(encode, "final", undefined),
21
+ "-f",
22
+ "null",
23
+ "-",
24
+ ];
25
+ }
26
+ // The filters a render runs in the computer's ffmpeg besides the encoder.
27
+ const neededFilters = ["zoompan", "perspective", "fillborders", "xfade", "ass"];
28
+ // Which ffmpeg can encode on an NVIDIA card. The bundled ffmpeg first, then the computer's own:
29
+ // unlike everything else, NVENC is the computer's (its driver and its ffmpeg), and only used
30
+ // when chosen in Settings. Asked for HEVC or AV1, the card that passed for H.264 is tested again
31
+ // with that codec's encoder, since older cards have no AV1 and the oldest no HEVC.
32
+ export function createNvencProbe(deps) {
33
+ const answers = new Map();
34
+ const ask = (codec) => {
35
+ let answer = answers.get(codec);
36
+ if (answer === undefined) {
37
+ answer = (codec === "h264"
38
+ ? probe(deps, {
39
+ label: "NVENC",
40
+ encoders: ["h264_nvenc"],
41
+ test: (bin) => testArgs({ kind: "nvenc", bin, clipSpeed: "thorough" }),
42
+ none: noNvenc,
43
+ failed: failedNvenc,
44
+ })
45
+ : ask("h264").then((card) => cardCodec(deps, card, codec))).catch((error) => ({
46
+ available: false,
47
+ reason: noNvenc,
48
+ detail: errorText(error),
49
+ }));
50
+ answers.set(codec, answer);
51
+ }
52
+ return answer;
53
+ };
54
+ return (codec = "h264") => ask(codec);
55
+ }
56
+ async function cardCodec(deps, card, codec) {
57
+ if (!card.available)
58
+ return card;
59
+ try {
60
+ await deps.exec(card.bin, testArgs({ kind: "nvenc", bin: card.bin, clipSpeed: "thorough", codec }));
61
+ return card;
62
+ }
63
+ catch (error) {
64
+ const detail = `the ${codec}_nvenc test encode through ${card.bin} failed: ${errorText(error)}`;
65
+ deps.log.write("info", "video.encoder", { detail });
66
+ return {
67
+ available: false,
68
+ reason: `This NVIDIA graphics card can't encode ${videoCodecLabels[codec]}.`,
69
+ detail,
70
+ };
71
+ }
72
+ }
73
+ // Which ffmpeg encodes AV1 on the processor with SVT-AV1. It also encodes the clips that are
74
+ // decoded again under captions, which stay H.264, so it needs x264 as well.
75
+ export function createSvtAv1Probe(deps) {
76
+ let answer;
77
+ return () => {
78
+ answer ??= probe(deps, {
79
+ label: "SVT-AV1",
80
+ encoders: ["libsvtav1", "libx264"],
81
+ test: (bin) => testArgs({ kind: "svtav1", bin, clipSpeed: "thorough" }),
82
+ none: noSvtAv1,
83
+ failed: failedSvtAv1,
84
+ }).catch((error) => ({
85
+ available: false,
86
+ reason: noSvtAv1,
87
+ detail: errorText(error),
88
+ }));
89
+ return answer;
90
+ };
91
+ }
92
+ async function probe(deps, want) {
93
+ const listed = (output, name) => new RegExp(`^\\s*V\\S*\\s+${name}\\s`, "m").test(output);
94
+ let failed;
95
+ for (const bin of new Set(deps.candidates)) {
96
+ const encoders = await deps.exec(bin, ["-hide_banner", "-encoders"]).catch(() => "");
97
+ if (!listed(encoders, want.encoders[0]))
98
+ continue;
99
+ const lacking = want.encoders.slice(1).filter((name) => !listed(encoders, name));
100
+ if (lacking.length > 0) {
101
+ failed = `the ffmpeg at ${bin} has ${want.label} but not the ${lacking.join(", ")} encoder a video needs`;
102
+ continue;
103
+ }
104
+ const filters = await deps.exec(bin, ["-hide_banner", "-filters"]).catch(() => "");
105
+ const missing = neededFilters.filter((name) => !new RegExp(`^\\s*\\S+\\s+${name}\\s`, "m").test(filters));
106
+ if (missing.length > 0) {
107
+ failed = `the ffmpeg at ${bin} has ${want.label} but not the ${missing.join(", ")} filter a video needs`;
108
+ continue;
109
+ }
110
+ try {
111
+ await deps.exec(bin, want.test(bin));
112
+ deps.log.write("info", "video.encoder", { detail: `${want.label} works through ${bin}` });
113
+ return { available: true, bin };
114
+ }
115
+ catch (error) {
116
+ failed = `the ffmpeg at ${bin} lists ${want.label} but its test encode failed: ${errorText(error)}`;
117
+ }
118
+ }
119
+ if (failed !== undefined) {
120
+ deps.log.write("info", "video.encoder", { detail: failed });
121
+ return { available: false, reason: want.failed, detail: failed };
122
+ }
123
+ return { available: false, reason: want.none };
124
+ }
@@ -1,9 +1,12 @@
1
1
  import { constants, setPriority } from "node:os";
2
2
  import { errorText } from "../../kernel/errors.js";
3
+ import { bt709Tags } from "./colour.js";
4
+ import { videoCodecLabels } from "./edit-settings.js";
3
5
  import { lookEncoding } from "./look.js";
4
6
  // Settings → Production defaults → Rendering: how this computer encodes a video's picture.
5
7
  // They change how a video is made, never what it is, so no recipe fingerprint carries them and
6
- // a render reads them once as it starts (`renderMachine`).
8
+ // a render reads them once as it starts (`renderMachine`). The finished video's codec is the
9
+ // project's (`edit-settings.ts`), and combines with them here.
7
10
  export const videoEncoders = ["cpu", "nvidia"];
8
11
  export const clipEncodeSpeeds = ["thorough", "fast"];
9
12
  export const renderPriorities = ["normal", "background"];
@@ -23,13 +26,39 @@ const intermediateCrf = "16";
23
26
  // size CRF 23 does, where NVENC scores about 2.5 VMAF below x264 (no NVENC setting tried closed
24
27
  // that gap at that size).
25
28
  export const nvencQuality = { intermediate: 20, final: 28.5 };
29
+ // measured on a real 3-minute stretch of a 1080p30 video, slow pan and zoom over dense
30
+ // engraving, each scoring about 94.4 VMAF against the H.264 file x264 makes today: SVT-AV1 at
31
+ // preset 6, CRF 36 is about 29% of its size at about 7x real time on 32 threads; av1_nvenc at
32
+ // CQ 34 about 44%; hevc_nvenc at CQ 27 about 59%. x265 at CRF 26 (preset medium) is not
33
+ // measured yet: a starting point expected to land near the same quality.
34
+ export const codecQuality = {
35
+ svtav1Preset: 6,
36
+ svtav1Crf: 36,
37
+ av1Nvenc: 34,
38
+ hevcNvenc: 27,
39
+ x265Crf: 26,
40
+ };
41
+ // measured on the first 24 shots of a real project, each still shown once (11.5 minutes, 32
42
+ // threads, changelog.d/2026-11-13-one-encode.md): clips that draw their own captions took
43
+ // 83 s at x264's default preset and 69 s at `faster`, for 1.2 VMAF less. That is the step
44
+ // Fast already was for clips encoded twice (118 s against 145 s, 0.7 VMAF less). `veryfast`
45
+ // cost 4.3 VMAF.
46
+ const captionedFastPreset = "faster";
47
+ // x264's own keyframe interval, so every clip, whatever its codec, opens on its one keyframe as
48
+ // x264's do and the clips still join by copying.
49
+ const keyframes = ["-g", "250"];
50
+ // HEVC in MP4 tagged hvc1 rather than hev1, which Apple's players and some browsers refuse.
51
+ const hvc1 = ["-tag:v", "hvc1"];
26
52
  // `final` is a picture someone watches (a clip joined by copying, a burned-in part, the join);
27
- // `intermediate` is a clip decoded again under burned-in captions.
53
+ // `intermediate` is a clip decoded again under burned-in captions, never watched, so it stays
54
+ // H.264 whatever the video's codec; `captioned` is a clip that draws its own captions, watched
55
+ // as it is.
28
56
  export function codecArgs(encode, role, look) {
29
- if (encode.kind === "nvenc")
57
+ if (encode.kind === "nvenc") {
58
+ const codec = role === "intermediate" ? undefined : encode.codec;
30
59
  return [
31
60
  "-c:v",
32
- "h264_nvenc",
61
+ `${codec ?? "h264"}_nvenc`,
33
62
  // The slowest, best preset, constant quality with no bitrate cap. No `-multipass`: measured,
34
63
  // a second full-resolution pass gave no better picture for its size on these videos.
35
64
  "-preset",
@@ -39,124 +68,160 @@ export function codecArgs(encode, role, look) {
39
68
  "-rc",
40
69
  "vbr",
41
70
  "-cq",
42
- String(nvencQuality[role]),
71
+ String(codec === "hevc"
72
+ ? codecQuality.hevcNvenc
73
+ : codec === "av1"
74
+ ? codecQuality.av1Nvenc
75
+ : nvencQuality[role === "intermediate" ? "intermediate" : "final"]),
43
76
  "-b:v",
44
77
  "0",
45
- // x264's own keyframe interval, so a clip opens on its one keyframe as x264's do and the
46
- // clips still join by copying.
47
- "-g",
48
- "250",
78
+ ...keyframes,
79
+ ...(codec === "hevc" ? hvc1 : []),
49
80
  "-pix_fmt",
50
81
  "yuv420p",
82
+ ...bt709Tags,
51
83
  ];
84
+ }
85
+ if (encode.kind === "x265" || encode.kind === "svtav1") {
86
+ if (role === "intermediate")
87
+ return codecArgs({ kind: "x264", clipSpeed: encode.clipSpeed }, role, look);
88
+ const common = ["-pix_fmt", "yuv420p", ...bt709Tags];
89
+ return encode.kind === "x265"
90
+ ? [
91
+ "-c:v",
92
+ "libx265",
93
+ ...common,
94
+ ...lookEncoding(look),
95
+ "-preset",
96
+ "medium",
97
+ "-crf",
98
+ String(codecQuality.x265Crf),
99
+ ...keyframes,
100
+ ...hvc1,
101
+ // x265 reports every frame's statistics on stderr otherwise.
102
+ "-x265-params",
103
+ "log-level=error",
104
+ ]
105
+ : [
106
+ "-c:v",
107
+ "libsvtav1",
108
+ ...common,
109
+ "-preset",
110
+ String(codecQuality.svtav1Preset),
111
+ "-crf",
112
+ String(codecQuality.svtav1Crf),
113
+ ...keyframes,
114
+ ];
115
+ }
116
+ const fast = encode.clipSpeed === "fast";
52
117
  return [
53
118
  "-c:v",
54
119
  "libx264",
55
120
  "-pix_fmt",
56
121
  "yuv420p",
122
+ ...bt709Tags,
57
123
  ...lookEncoding(look),
58
124
  ...(role === "intermediate"
59
- ? [...(encode.clipSpeed === "fast" ? ["-preset", "veryfast"] : []), "-crf", intermediateCrf]
60
- : []),
125
+ ? [...(fast ? ["-preset", "veryfast"] : []), "-crf", intermediateCrf]
126
+ : role === "captioned" && fast
127
+ ? ["-preset", captionedFastPreset]
128
+ : []),
61
129
  ];
62
130
  }
131
+ // What the join adds when it copies the clips: copying keeps the codec but not its MP4 tag.
132
+ export function copyTag(encode) {
133
+ return encode.kind === "x265" || (encode.kind === "nvenc" && encode.codec === "hevc") ? hvc1 : [];
134
+ }
135
+ // The ffmpeg that encodes the picture: the computer's own for NVENC and SVT-AV1, else the
136
+ // bundled one.
137
+ export function encoderBin(encode, bundled) {
138
+ return encode.kind === "nvenc" || encode.kind === "svtav1" ? encode.bin : bundled;
139
+ }
63
140
  // Said to a person who may have no NVIDIA card at all: stock ffmpeg builds list the NVIDIA
64
141
  // encoder everywhere, so a failed test usually means there is no card, not a broken one. What
65
142
  // the test printed goes under Details (`detail`), never into these sentences.
66
143
  export const noNvenc = "No NVIDIA graphics card was found on this computer.";
67
- export const failedNvenc = "No working NVIDIA graphics card was found on this computer.";
144
+ export const noSvtAv1 = "No ffmpeg with SVT-AV1 (libsvtav1) was found on this computer.";
68
145
  // The reason with the test's output, for the log and a run's notice.
69
146
  export function nvencWhy(status) {
70
147
  return status.detail === undefined ? status.reason : `${status.reason} (${status.detail})`;
71
148
  }
72
- // The renders' own settings on a tiny picture: a driver or card that refuses any of them fails
73
- // here rather than in a render. NVENC refuses anything under about 145 pixels across.
74
- const testArgs = [
75
- "-hide_banner",
76
- "-nostdin",
77
- "-loglevel",
78
- "error",
79
- "-f",
80
- "lavfi",
81
- "-i",
82
- "color=c=black:s=256x256:r=30:d=0.1",
83
- "-frames:v",
84
- "1",
85
- ...codecArgs({ kind: "nvenc", bin: "", clipSpeed: "thorough" }, "final", undefined),
86
- "-f",
87
- "null",
88
- "-",
89
- ];
90
- // The filters a render runs in the NVENC ffmpeg besides the encoder.
91
- const neededFilters = ["zoompan", "xfade", "ass"];
92
- // Which ffmpeg can encode on an NVIDIA card, asked once and remembered until Slopify restarts.
93
- // The bundled ffmpeg first, then the computer's own: unlike everything else, NVENC is the
94
- // computer's (its driver and its ffmpeg), and only used when chosen in Settings.
95
- export function createNvencProbe(deps) {
96
- let answer;
97
- return () => {
98
- answer ??= probe(deps).catch((error) => ({
99
- available: false,
100
- reason: noNvenc,
101
- detail: errorText(error),
102
- }));
103
- return answer;
104
- };
105
- }
106
- async function probe(deps) {
107
- let failed;
108
- for (const bin of new Set(deps.candidates)) {
109
- const encoders = await deps.exec(bin, ["-hide_banner", "-encoders"]).catch(() => "");
110
- if (!/^\s*V\S*\s+h264_nvenc\s/m.test(encoders))
111
- continue;
112
- const filters = await deps.exec(bin, ["-hide_banner", "-filters"]).catch(() => "");
113
- const missing = neededFilters.filter((name) => !new RegExp(`^\\s*\\S+\\s+${name}\\s`, "m").test(filters));
114
- if (missing.length > 0) {
115
- failed = `the ffmpeg at ${bin} has NVENC but not the ${missing.join(", ")} filter a video needs`;
116
- continue;
117
- }
118
- try {
119
- await deps.exec(bin, testArgs);
120
- deps.log.write("info", "video.encoder", { detail: `NVENC works through ${bin}` });
121
- return { available: true, bin };
122
- }
123
- catch (error) {
124
- failed = `the ffmpeg at ${bin} lists NVENC but its test encode failed: ${errorText(error)}`;
125
- }
126
- }
127
- if (failed !== undefined) {
128
- deps.log.write("info", "video.encoder", { detail: failed });
129
- return { available: false, reason: failedNvenc, detail: failed };
130
- }
131
- return { available: false, reason: noNvenc };
132
- }
133
- // The render's machine settings, read as it starts. A card chosen but not working is a notice,
134
- // never a failed render: the processor encodes it instead.
149
+ // The render's machine settings, read as it starts. Automatic is AV1 on the NVIDIA card
150
+ // whenever the card can encode it, whatever the Video encoder says, with today's H.264 as its
151
+ // `fallback`; without such a card it is today's H.264 render, said nowhere, since that is the
152
+ // ordinary way. An explicit encoder or codec chosen but not working is a notice, never a
153
+ // failed render: the processor encodes it instead, or H.264 does.
135
154
  export async function renderMachine(deps) {
136
- const { settings } = deps;
137
- const cpu = { kind: "x264", clipSpeed: settings.clipEncodeSpeed };
138
- if (settings.videoEncoder !== "nvidia")
139
- return { machine: { encode: cpu, priority: settings.renderPriority } };
140
- const status = await deps.nvenc();
141
- if (status.available)
142
- return {
143
- machine: {
144
- encode: { kind: "nvenc", bin: status.bin, clipSpeed: settings.clipEncodeSpeed },
145
- priority: settings.renderPriority,
155
+ if (deps.codec !== "auto")
156
+ return chosenMachine({ ...deps, codec: deps.codec ?? "h264" });
157
+ const today = await chosenMachine({ ...deps, codec: "h264" });
158
+ const card = await deps.nvenc();
159
+ if (!card.available)
160
+ return today;
161
+ const av1 = await deps.nvenc("av1");
162
+ if (!av1.available)
163
+ return today;
164
+ return {
165
+ machine: {
166
+ encode: {
167
+ kind: "nvenc",
168
+ bin: av1.bin,
169
+ clipSpeed: deps.settings.clipEncodeSpeed,
170
+ codec: "av1",
146
171
  },
147
- };
148
- deps.log.write("warn", "video.encoder", {
149
- projectId: deps.projectId,
150
- detail: `NVIDIA encoder chosen but unavailable; encoding on the processor. ${nvencWhy(status)}`,
172
+ priority: deps.settings.renderPriority,
173
+ fallback: today.machine.encode,
174
+ },
175
+ };
176
+ }
177
+ async function chosenMachine(deps) {
178
+ const { settings, codec } = deps;
179
+ const clipSpeed = settings.clipEncodeSpeed;
180
+ const warn = (detail) => deps.log.write("warn", "video.encoder", { projectId: deps.projectId, detail });
181
+ const done = (chosen) => ({
182
+ machine: { encode: chosen.encode, priority: settings.renderPriority },
183
+ ...(chosen.notices.length === 0 ? {} : { notice: chosen.notices.join(" ") }),
151
184
  });
152
- return {
153
- machine: { encode: cpu, priority: settings.renderPriority },
154
- notice: nvencFallbackNotice(nvencWhy(status)),
185
+ const cpu = async () => {
186
+ if (codec === "h264")
187
+ return { encode: { kind: "x264", clipSpeed }, notices: [] };
188
+ if (codec === "hevc")
189
+ return { encode: { kind: "x265", clipSpeed }, notices: [] };
190
+ const svt = (await deps.svtav1?.()) ?? { available: false, reason: noSvtAv1 };
191
+ if (svt.available)
192
+ return { encode: { kind: "svtav1", bin: svt.bin, clipSpeed }, notices: [] };
193
+ warn(`AV1 chosen but SVT-AV1 is unavailable; encoding H.264. ${nvencWhy(svt)}`);
194
+ return { encode: { kind: "x264", clipSpeed }, notices: [svtav1FallbackNotice(nvencWhy(svt))] };
155
195
  };
196
+ if (settings.videoEncoder !== "nvidia")
197
+ return done(await cpu());
198
+ const card = await deps.nvenc();
199
+ if (!card.available) {
200
+ warn(`NVIDIA encoder chosen but unavailable; encoding on the processor. ${nvencWhy(card)}`);
201
+ const chosen = await cpu();
202
+ return done({
203
+ encode: chosen.encode,
204
+ notices: [nvencFallbackNotice(nvencWhy(card)), ...chosen.notices],
205
+ });
206
+ }
207
+ const h264 = { kind: "nvenc", bin: card.bin, clipSpeed };
208
+ if (codec === "h264")
209
+ return done({ encode: h264, notices: [] });
210
+ const own = await deps.nvenc(codec);
211
+ if (own.available)
212
+ return done({ encode: { ...h264, bin: own.bin, codec }, notices: [] });
213
+ warn(`${videoCodecLabels[codec]} on the NVIDIA card is unavailable; encoding H.264 on it.`);
214
+ return done({ encode: h264, notices: [cardCodecNotice(codec, nvencWhy(own))] });
156
215
  }
157
216
  export function nvencFallbackNotice(reason) {
158
217
  return `This video was encoded on the processor because the NVIDIA graphics card encoder didn't work (${reason.replace(/\.$/, "")}). Check the NVIDIA driver, or choose Processor (x264) in Settings → Production defaults → Video encoder.`;
159
218
  }
219
+ export function svtav1FallbackNotice(reason) {
220
+ return `This video was encoded as H.264 instead of AV1 because AV1 on the processor needs an ffmpeg with SVT-AV1 (${reason.replace(/\.$/, "")}). Install an ffmpeg built with SVT-AV1 and restart Slopify, or choose H.264 or HEVC under Video codec in the project's Video settings.`;
221
+ }
222
+ function cardCodecNotice(codec, reason) {
223
+ return `This video was encoded as H.264 on the NVIDIA graphics card because it couldn't encode ${videoCodecLabels[codec]} (${reason.replace(/\.$/, "")}). Choose H.264${codec === "av1" ? " or HEVC" : ""} under Video codec in the project's Video settings, or Processor in Settings → Production defaults → Video encoder.`;
224
+ }
160
225
  // Background renders run below normal priority: nice 10 on Linux and macOS, the below-normal
161
226
  // class on Windows. Threads ffmpeg starts afterwards inherit it. Advisory: a system that
162
227
  // refuses is logged and the render carries on.