@gentbajko/slopify 4.3.3 → 4.3.5
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.
- package/dist/edge/http/settings.js +2 -0
- package/dist/extension/slopify-studio-chrome.zip +0 -0
- package/dist/extension/slopify-studio-firefox.zip +0 -0
- package/dist/main.js +8 -1
- package/dist/patch-notes/4.3.4.md +11 -0
- package/dist/patch-notes/4.3.5.md +30 -0
- package/dist/patch-notes/index.json +12 -0
- package/dist/slices/rebuild/runtime-export-short.js +4 -2
- package/dist/slices/rebuild/runtime-export.js +5 -2
- package/dist/slices/rebuild/runtime-plan.js +56 -0
- package/dist/slices/rebuild/runtime-provider.js +14 -0
- package/dist/slices/settings/model.js +1 -0
- package/dist/slices/settings/playback.js +11 -1
- package/dist/slices/studio/videos.js +20 -6
- package/dist/slices/video/encoding.js +5 -0
- package/dist/slices/video/plan.js +58 -11
- package/dist/slices/video/render-gate.js +45 -0
- package/dist/web/assets/{index-BwKV_9F3.js → index-Bvtq2QTE.js} +3 -3
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
|
@@ -50,6 +50,7 @@ const playbackBody = z.object({
|
|
|
50
50
|
videoEncoder: z.enum(videoEncoders).optional(),
|
|
51
51
|
clipEncodeSpeed: z.enum(clipEncodeSpeeds).optional(),
|
|
52
52
|
renderPriority: z.enum(renderPriorities).optional(),
|
|
53
|
+
videoRenderConcurrency: z.number().optional(),
|
|
53
54
|
});
|
|
54
55
|
// The return type is inferred so Hono keeps the route types the SPA's client is
|
|
55
56
|
// generated from; see stagingRoutes.
|
|
@@ -69,6 +70,7 @@ export function settingsRoutes(deps) {
|
|
|
69
70
|
videoEncoder: body.videoEncoder ?? saved.videoEncoder,
|
|
70
71
|
clipEncodeSpeed: body.clipEncodeSpeed ?? saved.clipEncodeSpeed,
|
|
71
72
|
renderPriority: body.renderPriority ?? saved.renderPriority,
|
|
73
|
+
videoRenderConcurrency: body.videoRenderConcurrency ?? saved.videoRenderConcurrency,
|
|
72
74
|
});
|
|
73
75
|
if (!result.ok) {
|
|
74
76
|
return problem(c, {
|
|
Binary file
|
|
Binary file
|
package/dist/main.js
CHANGED
|
@@ -121,6 +121,7 @@ import { createPriceCache } from "./slices/template-studio/service.js";
|
|
|
121
121
|
import { createTrashPurge } from "./slices/trash/service.js";
|
|
122
122
|
import { createNvencProbe, noNvenc, renderMachine, } from "./slices/video/encoding.js";
|
|
123
123
|
import { probeDurationMs, runFfmpegAt } from "./slices/video/ffmpeg.js";
|
|
124
|
+
import { createRenderGate } from "./slices/video/render-gate.js";
|
|
124
125
|
import { watchActivation } from "./updater/candidate.js";
|
|
125
126
|
import { launchUpdate } from "./updater/install.js";
|
|
126
127
|
import { isUpdateToken } from "./updater/model.js";
|
|
@@ -1072,7 +1073,10 @@ export async function boot(config, options = {}) {
|
|
|
1072
1073
|
}
|
|
1073
1074
|
export function wireRunner({ onFinished, audioPreviews, db, paths, clock, ids, log, hub, telemetry, flusher, registry, catalogue, ffmpeg, nvenc = async () => ({ available: false, reason: noNvenc }),
|
|
1074
1075
|
// Settings → Production defaults → Subtitle timing model, read as each alignment starts.
|
|
1075
|
-
alignSubtitles: aligner = alignSubtitlesWith(() => readSettings({ db, log }).subtitleModel),
|
|
1076
|
+
alignSubtitles: aligner = alignSubtitlesWith(() => readSettings({ db, log }).subtitleModel),
|
|
1077
|
+
// Settings → Production defaults → Videos rendered at once, read as each render asks for its
|
|
1078
|
+
// place, so a change takes hold without a restart.
|
|
1079
|
+
renderGate = createRenderGate(() => readSettings({ db, log }).videoRenderConcurrency), }) {
|
|
1076
1080
|
// A stage counts what it did and the queue is flushed after each new event. `record`
|
|
1077
1081
|
// swallows its own failures, so this can neither fail a stage nor widen what leaves the
|
|
1078
1082
|
// machine - the payload allow-list is checked inside it.
|
|
@@ -1090,6 +1094,9 @@ alignSubtitles: aligner = alignSubtitlesWith(() => readSettings({ db, log }).sub
|
|
|
1090
1094
|
alignSubtitles: aligner,
|
|
1091
1095
|
// Settings → Production defaults → Rendering, read as each render starts.
|
|
1092
1096
|
renderMachine: (projectId) => renderMachine({ settings: readSettings({ db, log }), nvenc, log, projectId }),
|
|
1097
|
+
// One queue for every render this computer makes, so a second video waits rather than
|
|
1098
|
+
// taking the processor and memory the first one and the page are using.
|
|
1099
|
+
renderGate,
|
|
1093
1100
|
audioPreviews,
|
|
1094
1101
|
count,
|
|
1095
1102
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Slopify 4.3.4
|
|
2
|
+
|
|
3
|
+
Released 10 November 2026.
|
|
4
|
+
|
|
5
|
+
The plan a run is made from is worked out once and shared, instead of again for every step that asks.
|
|
6
|
+
|
|
7
|
+
## A run no longer blocks the app
|
|
8
|
+
|
|
9
|
+
- **Ten places ask the project what it is making, and each worked it out from scratch** — the whole revision read back off disk, a check for every output and every picture, the article read again, every step derived from the narration up. With twelve pictures that was a few dozen times across a run and nobody saw it. With 240 it ran into the tens of thousands, one core went to nothing but that, and the app stopped answering.
|
|
10
|
+
- **It is now worked out once and handed to every caller that asks** while nothing it was made from has changed.
|
|
11
|
+
- **It is thrown away the moment anything does change** — any write to your data, a picture or an output whose file is no longer on disk, or a different model catalogue. The check is deliberately blunt, so it can only ever work the plan out more often than needed, never hand back one that has gone stale.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Slopify 4.3.5
|
|
2
|
+
|
|
3
|
+
Released 12 November 2026.
|
|
4
|
+
|
|
5
|
+
The picture is now timed to the narration, a run no longer takes the whole computer, and a video's shorts stay in Ready to upload until every one of them is up.
|
|
6
|
+
|
|
7
|
+
## Each image holds for its share of the narration
|
|
8
|
+
|
|
9
|
+
- **A shot's length is now worked out from the narration it covers** — the time left after the figure cards, divided by the number of images — rather than from a fixed number of seconds. The images a video was made with span the whole video, in order, each one once.
|
|
10
|
+
- **A sparse set still keeps cutting.** Where dividing the narration that way would leave one image on screen for more than two minutes, the shot falls back to the length set for the project, so the picture keeps moving rather than settling on a still.
|
|
11
|
+
- **Measured on a real episode:** 240 images now plan 244 shots across the whole timeline.
|
|
12
|
+
|
|
13
|
+
## This computer renders one video at a time
|
|
14
|
+
|
|
15
|
+
- **Settings → Production defaults → Videos rendered at once,** one to four, one by default. A render decodes a whole picture track and encodes hours of it, so a second one does not take half the time each: they share the processor, the disk and the memory, and enough of them together leave the app with too little of each to answer the page.
|
|
16
|
+
- **A render that has to wait is not refused,** it takes its turn and finishes later. Shorts queue beside long videos, since a short is a render like any other.
|
|
17
|
+
- **The audio export does not queue.** It is neither long enough nor heavy enough to be worth holding a place for, so turning narration into a WAV never waits behind a video.
|
|
18
|
+
- **The number is read as each render asks for its place,** so raising it lets a waiting render start without a restart, and lowering it takes hold as the renders running now finish.
|
|
19
|
+
|
|
20
|
+
## A video's shorts stay in Ready to upload until they are up
|
|
21
|
+
|
|
22
|
+
- **The project's uploaded mark now stands for every upload it has,** the long video and each short, not for the long video alone. It was one fact before — the long video on YouTube meant the project was uploaded — and that quietly took the shorts still waiting out of Ready to upload with it.
|
|
23
|
+
- **Why it bit:** Studio re-reads the long video after each upload. Uploading short 1 made Slopify record the long video again, which re-applied the mark, which hid shorts 2 and 3. The extension then said "Nothing waits to be uploaded" while two shorts had never gone up, and taking the mark off by hand lasted only until the next upload re-applied it.
|
|
24
|
+
- **Nothing changed about what the extension already knew:** every item in its list carried its own uploaded flag all along. Only the project-level mark was wrong, so Projects, Home, the calendar and the extension now agree without any of them being taught about shorts.
|
|
25
|
+
- **Forgetting an upload that was on YouTube takes the mark off again,** a short's as well as the long video's, since the mark stands for all of them. An upload only filled in Studio never set the mark, so forgetting it still leaves a mark made by hand.
|
|
26
|
+
|
|
27
|
+
## New images appear as they are made
|
|
28
|
+
|
|
29
|
+
- **The open page now hears about each image as it lands,** so the pictures fill in while a run works instead of only when you reload. The progress beside them already moved live; the pictures themselves did not.
|
|
30
|
+
- **A long run does not flood the page.** A run of 240 images collapses into a few refreshes rather than one for every image.
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"id": "4.3.5",
|
|
4
|
+
"title": "Slopify 4.3.5",
|
|
5
|
+
"version": "4.3.5",
|
|
6
|
+
"date": "2026-11-12"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"id": "4.3.4",
|
|
10
|
+
"title": "Slopify 4.3.4",
|
|
11
|
+
"version": "4.3.4",
|
|
12
|
+
"date": "2026-11-10"
|
|
13
|
+
},
|
|
2
14
|
{
|
|
3
15
|
"id": "4.3.3",
|
|
4
16
|
"title": "Slopify 4.3.3",
|
|
@@ -5,6 +5,7 @@ import { renderShort, shortFrame } from "../shorts/render.js";
|
|
|
5
5
|
import { allocateAsset, discardPreparedAssets, sealAsset } from "../storage/assets.js";
|
|
6
6
|
import { projectDir } from "../storage/layout.js";
|
|
7
7
|
import { probeDurationMs } from "../video/ffmpeg.js";
|
|
8
|
+
import { openRenderGate } from "../video/render-gate.js";
|
|
8
9
|
import { exportMachine, slideshowImages, warningsOf, } from "./runtime-export.js";
|
|
9
10
|
import { preparedResult, preparedText, publishResult } from "./runtime-publication.js";
|
|
10
11
|
import { readTimingWords } from "./runtime-subtitles.js";
|
|
@@ -29,7 +30,8 @@ export async function executeShortExport(deps, context, piece, snapshot, timelin
|
|
|
29
30
|
const relativePath = (path) => relative(directory, path).split(sep).join("/");
|
|
30
31
|
try {
|
|
31
32
|
const machine = await exportMachine(deps, context.work.projectId);
|
|
32
|
-
|
|
33
|
+
// A short is a render like any other, so it waits in the same queue as the long video.
|
|
34
|
+
const master = await (deps.renderGate ?? openRenderGate).hold(() => renderShort({
|
|
33
35
|
bin: deps.ffmpeg,
|
|
34
36
|
machine: machine.machine,
|
|
35
37
|
notice: machine.notice,
|
|
@@ -55,7 +57,7 @@ export async function executeShortExport(deps, context, piece, snapshot, timelin
|
|
|
55
57
|
current: Math.min(100, Math.round(elapsedMs / (seconds * 10))),
|
|
56
58
|
total: 100,
|
|
57
59
|
}),
|
|
58
|
-
});
|
|
60
|
+
}));
|
|
59
61
|
context.signal.throwIfAborted();
|
|
60
62
|
const durationMs = await probeDurationMs(deps.ffmpeg, pending.absolutePath, context.signal, deps.log);
|
|
61
63
|
const asset = sealAsset(deps, pending);
|
|
@@ -12,6 +12,7 @@ import { audioExportArgs } from "../video/audio-export.js";
|
|
|
12
12
|
import { withPaths } from "../video/edit-list.js";
|
|
13
13
|
import { runFfmpeg } from "../video/ffmpeg.js";
|
|
14
14
|
import { planRender } from "../video/plan.js";
|
|
15
|
+
import { openRenderGate } from "../video/render-gate.js";
|
|
15
16
|
import { renderSlideshow } from "../video/slideshow.js";
|
|
16
17
|
import { writePortraits } from "../voices/portraits.js";
|
|
17
18
|
import { linesLevelled } from "./recipe-lines.js";
|
|
@@ -197,8 +198,10 @@ export async function executeExportRecipe(deps, context, piece) {
|
|
|
197
198
|
}
|
|
198
199
|
}
|
|
199
200
|
}
|
|
201
|
+
// The picture render waits its turn. The audio export above does not: it is neither long
|
|
202
|
+
// enough nor heavy enough to be worth holding a place for.
|
|
200
203
|
else
|
|
201
|
-
master = await renderSlideshow({
|
|
204
|
+
master = await (deps.renderGate ?? openRenderGate).hold(() => renderSlideshow({
|
|
202
205
|
bin: deps.ffmpeg,
|
|
203
206
|
edit: plan.editList,
|
|
204
207
|
output: plan.output,
|
|
@@ -213,7 +216,7 @@ export async function executeExportRecipe(deps, context, piece) {
|
|
|
213
216
|
...(goal === undefined ? {} : { master: goal }),
|
|
214
217
|
machine: machine.machine,
|
|
215
218
|
notice: machine.notice,
|
|
216
|
-
});
|
|
219
|
+
}));
|
|
217
220
|
context.signal.throwIfAborted();
|
|
218
221
|
const asset = sealAsset(deps, pending);
|
|
219
222
|
prepared.push(preparedResult(deps, context, piece, wav ? "audio_export" : "video", asset, Math.round(totalSeconds * 1000), {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { catalogueSchema } from "../../catalog/schema.js";
|
|
4
|
+
import { fingerprint } from "../../kernel/runner/work.js";
|
|
4
5
|
import { getRevisionView, readyOutput, withEarlierJoins } from "../revisions/view.js";
|
|
5
6
|
import { outputPath } from "../storage/layout.js";
|
|
6
7
|
import { referencedAssetsAvailable, retainedNarrationPieces } from "./narration-history.js";
|
|
@@ -51,7 +52,62 @@ export function workLlm(db, workId, choice, label) {
|
|
|
51
52
|
...call,
|
|
52
53
|
});
|
|
53
54
|
}
|
|
55
|
+
// Ten places ask for the plan, and each one used to derive it from scratch: the article read
|
|
56
|
+
// back off disk, every recipe rebuilt from the narration up. At twelve images that happened a
|
|
57
|
+
// few dozen times over a run; at 240 it happened tens of thousands of times and the server
|
|
58
|
+
// spent its whole time planning instead of answering.
|
|
59
|
+
//
|
|
60
|
+
// The plan is kept and handed back while nothing in the database has changed, which SQLite
|
|
61
|
+
// counts for us. That is a blunt test on purpose: a write anywhere - another project, another
|
|
62
|
+
// revision - throws the plan away and it is derived again. It can never hand back a plan from
|
|
63
|
+
// after a write it has not seen, which is the only direction that would matter, because a
|
|
64
|
+
// stale plan would start the wrong work.
|
|
65
|
+
// Per database, never shared between them: two of them (the app and a mirror, or two tests)
|
|
66
|
+
// can hold the same project under the same id, and one's plan is not the other's.
|
|
67
|
+
const kept = new WeakMap();
|
|
68
|
+
const changeCount = z.object({ changes: z.number() });
|
|
69
|
+
function writesSoFar(deps) {
|
|
70
|
+
return changeCount.parse(deps.db.prepare("SELECT total_changes() AS changes").get()).changes;
|
|
71
|
+
}
|
|
72
|
+
// Two catalogues that differ give different plans, so the catalogue belongs in the key. Its
|
|
73
|
+
// date and shape identify it without hashing the whole of it on every call.
|
|
74
|
+
function catalogueMark(catalogue) {
|
|
75
|
+
return [
|
|
76
|
+
catalogue.schemaVersion,
|
|
77
|
+
catalogue.updatedAt,
|
|
78
|
+
catalogue.llm.length,
|
|
79
|
+
catalogue.image?.length ?? 0,
|
|
80
|
+
Object.keys(catalogue.providers).length,
|
|
81
|
+
].join("/");
|
|
82
|
+
}
|
|
83
|
+
// What the plan was derived from, beyond the database: whether each output and piece is
|
|
84
|
+
// selected and whether its file is still on disk. A file deleted by hand is no write at all,
|
|
85
|
+
// so `total_changes()` would never notice it, and the plan would go on reusing work whose
|
|
86
|
+
// output is gone. Walking a few hundred rows is nothing beside deriving the plan again.
|
|
87
|
+
function viewMark(view) {
|
|
88
|
+
const rows = [String(view.articleMarkdown?.length ?? -1)];
|
|
89
|
+
for (const row of view.outputs)
|
|
90
|
+
rows.push(`o${row.recordId}:${row.selected ? 1 : 0}${row.available ? 1 : 0}:${row.fingerprint}`);
|
|
91
|
+
for (const row of view.pieces)
|
|
92
|
+
rows.push(`p${row.recordId}:${row.selected ? 1 : 0}${row.available ? 1 : 0}:${row.fingerprint}`);
|
|
93
|
+
return fingerprint(rows.join("\n"));
|
|
94
|
+
}
|
|
54
95
|
export function executionPlan(deps, view, catalogue) {
|
|
96
|
+
const key = `${view.revision.projectId}/${view.revision.id}/${catalogueMark(catalogue)}/${viewMark(view)}`;
|
|
97
|
+
const changes = writesSoFar(deps);
|
|
98
|
+
const forDb = kept.get(deps.db) ?? new Map();
|
|
99
|
+
kept.set(deps.db, forDb);
|
|
100
|
+
const held = forDb.get(key);
|
|
101
|
+
if (held !== undefined && held.changes === changes)
|
|
102
|
+
return held.plan;
|
|
103
|
+
const plan = derivePlan(deps, view, catalogue);
|
|
104
|
+
// A cache, not a store: a handful of revisions is all a run needs at once.
|
|
105
|
+
if (forDb.size > 8)
|
|
106
|
+
forDb.clear();
|
|
107
|
+
forDb.set(key, { changes, plan });
|
|
108
|
+
return plan;
|
|
109
|
+
}
|
|
110
|
+
function derivePlan(deps, view, catalogue) {
|
|
55
111
|
const textOutput = (role) => {
|
|
56
112
|
const row = readyOutput(view, { role });
|
|
57
113
|
return row === undefined
|
|
@@ -161,6 +161,20 @@ export async function executeProviderRecipe(deps, context, providers, piece) {
|
|
|
161
161
|
...(variant === undefined || variant === 1 ? {} : { index: variant }),
|
|
162
162
|
});
|
|
163
163
|
await publishResult(deps, context, piece, [output], { prompt }, asset);
|
|
164
|
+
// The frame names the output and its place, not the row or the file behind them, so the
|
|
165
|
+
// open page refetches on it rather than painting from it (`web/src/events.ts`); a run of
|
|
166
|
+
// 240 images coalesces those refetches there, so every image still sends its own frame.
|
|
167
|
+
context.emit({
|
|
168
|
+
type: "image.landed",
|
|
169
|
+
projectId: context.work.projectId,
|
|
170
|
+
outputId: output.output.id,
|
|
171
|
+
// Thumbnails and the establishing image have no place in the image order; the page
|
|
172
|
+
// refetches on any of them just the same.
|
|
173
|
+
index: index ?? 0,
|
|
174
|
+
revisionId: context.work.revisionId,
|
|
175
|
+
workId: context.work.workId,
|
|
176
|
+
workPieceId: piece.id,
|
|
177
|
+
});
|
|
164
178
|
if (softened !== undefined)
|
|
165
179
|
clearSoftening(deps.db, context.work.projectId, [piece.key]);
|
|
166
180
|
deps.count?.("stage.completed", {
|
|
@@ -2,7 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { englishSubtitleModels } from "../../kernel/ports/subtitles.js";
|
|
3
3
|
import { silenceGapSecondsMax } from "../admission/rules.js";
|
|
4
4
|
import { loudnessFields } from "../loudness/model.js";
|
|
5
|
-
import { clipEncodeSpeeds, renderPriorities, videoEncoders } from "../video/encoding.js";
|
|
5
|
+
import { clipEncodeSpeeds, renderPriorities, videoEncoders, videoRenderConcurrencyMax, } from "../video/encoding.js";
|
|
6
6
|
import { appearances, defaultSettings } from "./model.js";
|
|
7
7
|
import { readJsonSetting, writeSetting } from "./repo.js";
|
|
8
8
|
// The `settings` table is key/value, so each setting is its own row and a value the app
|
|
@@ -14,12 +14,14 @@ const subtitleModelKey = "subtitleModel";
|
|
|
14
14
|
const videoEncoderKey = "videoEncoder";
|
|
15
15
|
const clipEncodeSpeedKey = "clipEncodeSpeed";
|
|
16
16
|
const renderPriorityKey = "renderPriority";
|
|
17
|
+
const videoRenderConcurrencyKey = "videoRenderConcurrency";
|
|
17
18
|
const silenceGapValue = z.number().int().min(0).max(silenceGapSecondsMax);
|
|
18
19
|
const appearanceValue = z.enum(appearances);
|
|
19
20
|
const subtitleModelValue = z.enum(englishSubtitleModels);
|
|
20
21
|
const videoEncoderValue = z.enum(videoEncoders);
|
|
21
22
|
const clipEncodeSpeedValue = z.enum(clipEncodeSpeeds);
|
|
22
23
|
const renderPriorityValue = z.enum(renderPriorities);
|
|
24
|
+
const videoRenderConcurrencyValue = z.number().int().min(1).max(videoRenderConcurrencyMax);
|
|
23
25
|
const loudnessValue = z.object({
|
|
24
26
|
enabled: z.boolean(),
|
|
25
27
|
videoLufs: z.number(),
|
|
@@ -34,6 +36,7 @@ export function readSettings(deps) {
|
|
|
34
36
|
videoEncoder: parsed(deps, videoEncoderKey, videoEncoderValue, defaultSettings.videoEncoder),
|
|
35
37
|
clipEncodeSpeed: parsed(deps, clipEncodeSpeedKey, clipEncodeSpeedValue, defaultSettings.clipEncodeSpeed),
|
|
36
38
|
renderPriority: parsed(deps, renderPriorityKey, renderPriorityValue, defaultSettings.renderPriority),
|
|
39
|
+
videoRenderConcurrency: parsed(deps, videoRenderConcurrencyKey, videoRenderConcurrencyValue, defaultSettings.videoRenderConcurrency),
|
|
37
40
|
};
|
|
38
41
|
}
|
|
39
42
|
export function saveSettings(deps, settings) {
|
|
@@ -77,6 +80,12 @@ export function saveSettings(deps, settings) {
|
|
|
77
80
|
message: "Choose Normal or Background in Settings → Production defaults → Encoding priority.",
|
|
78
81
|
});
|
|
79
82
|
}
|
|
83
|
+
if (!videoRenderConcurrencyValue.safeParse(settings.videoRenderConcurrency).success) {
|
|
84
|
+
fields.push({
|
|
85
|
+
field: "videoRenderConcurrency",
|
|
86
|
+
message: `Enter a whole number between 1 and ${String(videoRenderConcurrencyMax)} in Settings → Production defaults → Videos rendered at once.`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
80
89
|
if (fields.length > 0) {
|
|
81
90
|
return { ok: false, fields };
|
|
82
91
|
}
|
|
@@ -87,6 +96,7 @@ export function saveSettings(deps, settings) {
|
|
|
87
96
|
writeSetting(deps.db, videoEncoderKey, JSON.stringify(settings.videoEncoder));
|
|
88
97
|
writeSetting(deps.db, clipEncodeSpeedKey, JSON.stringify(settings.clipEncodeSpeed));
|
|
89
98
|
writeSetting(deps.db, renderPriorityKey, JSON.stringify(settings.renderPriority));
|
|
99
|
+
writeSetting(deps.db, videoRenderConcurrencyKey, JSON.stringify(settings.videoRenderConcurrency));
|
|
90
100
|
return { ok: true, settings };
|
|
91
101
|
}
|
|
92
102
|
// A stored value is JSON, and a hand-edited database is the only way it can be anything
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { outputsOf } from "../storage/repo.js";
|
|
1
2
|
import { markUploaded } from "../uploads/repo.js";
|
|
2
3
|
const taskState = (value) => value === "waiting" || value === "done" || value === "failed" ? value : "none";
|
|
3
4
|
// A YouTube video id: 11 letters, digits, `-` and `_`.
|
|
@@ -12,6 +13,18 @@ export function videoIdOf(text) {
|
|
|
12
13
|
return match?.[1];
|
|
13
14
|
}
|
|
14
15
|
const slot = (short) => short ?? 0;
|
|
16
|
+
// Every upload the project has is on YouTube: the long video, and each short it rendered
|
|
17
|
+
// (`short_video`, the outputs the pack lists). A project whose long video is up while a short
|
|
18
|
+
// still waits is not uploaded, so the short keeps its place in Ready to upload.
|
|
19
|
+
function allOnYoutube(db, projectId) {
|
|
20
|
+
if (videoOf(db, projectId, null)?.uploadState !== "done")
|
|
21
|
+
return false;
|
|
22
|
+
const shorts = new Set(outputsOf(db, projectId)
|
|
23
|
+
.filter((output) => output.role === "short_video")
|
|
24
|
+
.map((output) => output.meta.short)
|
|
25
|
+
.filter((number) => number !== undefined));
|
|
26
|
+
return [...shorts].every((number) => videoOf(db, projectId, number)?.uploadState === "done");
|
|
27
|
+
}
|
|
15
28
|
function rowOf(row) {
|
|
16
29
|
const short = Number(row.short);
|
|
17
30
|
return {
|
|
@@ -42,7 +55,7 @@ export function recordVideo(db, projectId, short, videoId, at, state = "done") {
|
|
|
42
55
|
upload_state=CASE WHEN video_id=excluded.video_id AND upload_state='done' THEN 'done'
|
|
43
56
|
ELSE excluded.upload_state END,
|
|
44
57
|
video_id=excluded.video_id, recorded_at=excluded.recorded_at`).run(projectId, slot(short), videoId, at, state);
|
|
45
|
-
if (
|
|
58
|
+
if (allOnYoutube(db, projectId))
|
|
46
59
|
markUploaded(db, projectId, true, at);
|
|
47
60
|
}
|
|
48
61
|
// Studio said the upload was scheduled or published. False when no such upload was filled.
|
|
@@ -50,17 +63,18 @@ export function confirmUpload(db, projectId, short, videoId, at) {
|
|
|
50
63
|
const confirmed = db
|
|
51
64
|
.prepare("UPDATE youtube_videos SET upload_state='done' WHERE project_id=? AND short=? AND video_id=?")
|
|
52
65
|
.run(projectId, slot(short), videoId).changes > 0;
|
|
53
|
-
if (confirmed &&
|
|
66
|
+
if (confirmed && allOnYoutube(db, projectId))
|
|
54
67
|
markUploaded(db, projectId, true, at);
|
|
55
68
|
return confirmed;
|
|
56
69
|
}
|
|
57
|
-
// Forgets the video an upload became (deleted on YouTube, or a wrong link). Forgetting
|
|
58
|
-
//
|
|
59
|
-
//
|
|
70
|
+
// Forgets the video an upload became (deleted on YouTube, or a wrong link). Forgetting one
|
|
71
|
+
// that was on YouTube - the long video or a short - takes the project's uploaded mark off with
|
|
72
|
+
// it, since the mark stands for all of them; an upload only filled in Studio never set the
|
|
73
|
+
// mark, so forgetting it leaves a mark made by hand.
|
|
60
74
|
export function forgetVideo(db, projectId, short, at) {
|
|
61
75
|
const was = videoOf(db, projectId, short);
|
|
62
76
|
db.prepare("DELETE FROM youtube_videos WHERE project_id=? AND short=?").run(projectId, slot(short));
|
|
63
|
-
if (
|
|
77
|
+
if (was?.uploadState === "done" && !allOnYoutube(db, projectId))
|
|
64
78
|
markUploaded(db, projectId, false, at);
|
|
65
79
|
}
|
|
66
80
|
// "Mark not uploaded" (Home, Projects): the long video's link goes with the mark, so the two
|
|
@@ -7,6 +7,11 @@ import { lookEncoding } from "./look.js";
|
|
|
7
7
|
export const videoEncoders = ["cpu", "nvidia"];
|
|
8
8
|
export const clipEncodeSpeeds = ["thorough", "fast"];
|
|
9
9
|
export const renderPriorities = ["normal", "background"];
|
|
10
|
+
// How many videos this computer renders at once. A render reads the whole picture track and
|
|
11
|
+
// encodes hours of it, so two at once cost more than twice one: they share the processor, the
|
|
12
|
+
// disk and the memory, and a long enough pair can leave the app with nothing to answer the
|
|
13
|
+
// page with. One at a time is the default; the rest wait their turn rather than being refused.
|
|
14
|
+
export const videoRenderConcurrencyMax = 4;
|
|
10
15
|
// Today's render: x264 at its default preset, at normal priority.
|
|
11
16
|
export const defaultEncode = { kind: "x264", clipSpeed: "thorough" };
|
|
12
17
|
// Clips that are joined by copying get the final encode's settings. Clips that will be decoded
|
|
@@ -55,18 +55,20 @@ export function planRender(input) {
|
|
|
55
55
|
const totalFrames = Math.max(1, Math.round(totalSeconds * fps));
|
|
56
56
|
const edit = input.edit;
|
|
57
57
|
const narration = input.body === undefined ? undefined : edit?.narration;
|
|
58
|
+
const figures = figureFrames(edit?.figures ?? [], totalFrames);
|
|
59
|
+
const figureTotal = figures.reduce((sum, figure) => sum + figure.frames, 0);
|
|
60
|
+
const shotSeconds = holdSeconds(input, Math.max(0, totalFrames - figureTotal) / fps);
|
|
58
61
|
const lengthsFor = (from, frameCount) => narration === undefined
|
|
59
|
-
? everyLengths(Math.max(1, Math.round(
|
|
62
|
+
? everyLengths(Math.max(1, Math.round(shotSeconds * fps)), frameCount)
|
|
60
63
|
: narrationShotFrames({
|
|
61
64
|
totalFrames: frameCount,
|
|
62
65
|
fps,
|
|
63
|
-
imageSeconds:
|
|
66
|
+
imageSeconds: shotSeconds,
|
|
64
67
|
cutPoints: narration.cutPoints.map((point) => point - from / fps),
|
|
65
68
|
chapterStarts: narration.chapterStarts
|
|
66
69
|
.map((start) => start - from / fps)
|
|
67
70
|
.filter((start) => start >= 0 && start < frameCount / fps),
|
|
68
71
|
});
|
|
69
|
-
const figures = figureFrames(edit?.figures ?? [], totalFrames);
|
|
70
72
|
const planned = figures.length === 0
|
|
71
73
|
? shots(input, lengthsFor(0, totalFrames))
|
|
72
74
|
: aroundFigures(input, figures, totalFrames, lengthsFor);
|
|
@@ -77,7 +79,7 @@ export function planRender(input) {
|
|
|
77
79
|
return {
|
|
78
80
|
gapSeconds: input.gapSeconds,
|
|
79
81
|
edgeSeconds: input.edgeSeconds,
|
|
80
|
-
imageSeconds:
|
|
82
|
+
imageSeconds: shotSeconds,
|
|
81
83
|
zoomPercent: input.zoomPercent,
|
|
82
84
|
motionStyle: input.motionStyle,
|
|
83
85
|
editList: {
|
|
@@ -202,18 +204,53 @@ export function audioTimeline(input, minimumGap = 1 / fps) {
|
|
|
202
204
|
}
|
|
203
205
|
// Every N seconds: each shot `each` frames until the timeline is full; the last shot is cut
|
|
204
206
|
// to what is left. A timeline shorter than one shot is a single shot.
|
|
207
|
+
// How long one image stays on screen. Each image is made for one moment of the narration, so
|
|
208
|
+
// the shot length follows how many images there are rather than a fixed setting: Seconds per
|
|
209
|
+
// image on its own decides the shot count and then replays the set to fill the timeline, which
|
|
210
|
+
// at 240 images over two and a half hours played the whole set through two and a half times and
|
|
211
|
+
// brought the opening illustrations back over the closing chapters. Seconds per image stays the
|
|
212
|
+
// floor, so a project never cuts faster than it asked for, and `maxHoldSeconds` the ceiling, so
|
|
213
|
+
// a handful of images over a long narration still cuts, and moves, rather than holding one
|
|
214
|
+
// frame for a quarter of an hour. A silent video already shows every image once, and a short's
|
|
215
|
+
// images are counted from Seconds per image to begin with (`shortImageCount`), so both come out
|
|
216
|
+
// unchanged.
|
|
217
|
+
const maxHoldSeconds = 120;
|
|
218
|
+
function holdSeconds(input, fillSeconds) {
|
|
219
|
+
// One image has no order to follow, so it keeps its own slots and the motion that alternates
|
|
220
|
+
// across them rather than becoming a single still held for the whole narration.
|
|
221
|
+
if (input.body === undefined || input.images.length < 2)
|
|
222
|
+
return input.imageSeconds;
|
|
223
|
+
const share = fillSeconds / input.images.length;
|
|
224
|
+
if (!Number.isFinite(share) || share <= 0)
|
|
225
|
+
return input.imageSeconds;
|
|
226
|
+
// Past this, one image would sit on screen for minutes on end. The shots stay at the pace the
|
|
227
|
+
// project asked for, so the motion keeps refreshing across a long hold (`motion.ts`); the
|
|
228
|
+
// images still go in order, one after another, and none of them comes round twice.
|
|
229
|
+
if (share > maxHoldSeconds)
|
|
230
|
+
return input.imageSeconds;
|
|
231
|
+
return Math.max(input.imageSeconds, share);
|
|
232
|
+
}
|
|
233
|
+
// Which image a shot shows: the images in order, spread evenly over the shots. More shots than
|
|
234
|
+
// images holds a few of them over two shots in a row rather than starting the set over, and
|
|
235
|
+
// more images than shots leaves some out rather than dropping the whole tail of the set.
|
|
236
|
+
function imageAt(at, total, images) {
|
|
237
|
+
if (images <= 0 || total <= 0)
|
|
238
|
+
return 0;
|
|
239
|
+
return Math.min(images - 1, Math.floor((at * images) / total));
|
|
240
|
+
}
|
|
205
241
|
function everyLengths(each, totalFrames) {
|
|
206
242
|
const count = Math.ceil(totalFrames / each);
|
|
207
243
|
return Array.from({ length: count }, (_value, at) => Math.min(each, totalFrames - each * at));
|
|
208
244
|
}
|
|
209
|
-
// The images
|
|
210
|
-
//
|
|
211
|
-
//
|
|
212
|
-
//
|
|
213
|
-
|
|
245
|
+
// The images in order, one per shot, spread over the whole timeline (`imageAt`). The motion
|
|
246
|
+
// goes by the shot's place, not the image (`motion.ts`), so an image held over two shots may
|
|
247
|
+
// move another way in the second. A moving clip in an image's place plays as it is, with no
|
|
248
|
+
// motion of its own. `total` is every shot in the timeline, not just this stretch of it, so
|
|
249
|
+
// the figures do not restart the set.
|
|
250
|
+
function shots(input, lengths, first = 0, total = lengths.length) {
|
|
214
251
|
return lengths.map((frames, place) => {
|
|
215
252
|
const at = first + place;
|
|
216
|
-
const index = at
|
|
253
|
+
const index = imageAt(at, total, input.images.length);
|
|
217
254
|
const clip = input.edit?.clips?.[index];
|
|
218
255
|
return clip === undefined
|
|
219
256
|
? {
|
|
@@ -252,6 +289,16 @@ export function figureFrames(figures, totalFrames) {
|
|
|
252
289
|
// whole video of that length, and keep counting across them so no image or motion repeats
|
|
253
290
|
// where a card interrupts. Each card is shown still, whole.
|
|
254
291
|
function aroundFigures(input, figures, totalFrames, lengthsFor) {
|
|
292
|
+
const lengthsAt = (from, to) => to > from ? lengthsFor(from, to - from) : [];
|
|
293
|
+
// Every stretch is measured before any image is placed, so the images spread over all of
|
|
294
|
+
// them together rather than starting the set over after each figure.
|
|
295
|
+
let total = 0;
|
|
296
|
+
let measured = 0;
|
|
297
|
+
for (const figure of figures) {
|
|
298
|
+
total += lengthsAt(measured, figure.startFrame).length;
|
|
299
|
+
measured = figure.startFrame + figure.frames;
|
|
300
|
+
}
|
|
301
|
+
total += lengthsAt(measured, totalFrames).length;
|
|
255
302
|
const out = [];
|
|
256
303
|
let cursor = 0;
|
|
257
304
|
let slot = 0;
|
|
@@ -259,7 +306,7 @@ function aroundFigures(input, figures, totalFrames, lengthsFor) {
|
|
|
259
306
|
if (to <= cursor)
|
|
260
307
|
return;
|
|
261
308
|
const lengths = lengthsFor(cursor, to - cursor);
|
|
262
|
-
out.push(...shots(input, lengths, slot));
|
|
309
|
+
out.push(...shots(input, lengths, slot, total));
|
|
263
310
|
slot += lengths.length;
|
|
264
311
|
cursor = to;
|
|
265
312
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// How many videos this computer renders at once (Settings → Production defaults → Videos
|
|
2
|
+
// rendered at once). A render decodes the whole picture track and encodes hours of it, so two
|
|
3
|
+
// at once cost more than twice one: they share the processor, the disk and the memory, and
|
|
4
|
+
// enough of them together leave the app with too little of each to answer the page.
|
|
5
|
+
//
|
|
6
|
+
// A render holds a place for as long as it runs; the rest wait their turn rather than being
|
|
7
|
+
// refused, so a waiting render still finishes, only later. The limit is read each time a place
|
|
8
|
+
// is asked for and each time one is given back, so raising it in Settings lets a waiting render
|
|
9
|
+
// start without a restart, and lowering it takes effect as the renders running now finish.
|
|
10
|
+
import { videoRenderConcurrencyMax } from "./encoding.js";
|
|
11
|
+
export function createRenderGate(limit) {
|
|
12
|
+
const waiting = [];
|
|
13
|
+
let active = 0;
|
|
14
|
+
// A hand-edited setting cannot make the gate let everything through, or nothing.
|
|
15
|
+
const allowed = () => {
|
|
16
|
+
const asked = Math.floor(limit());
|
|
17
|
+
return Number.isFinite(asked) ? Math.max(1, Math.min(videoRenderConcurrencyMax, asked)) : 1;
|
|
18
|
+
};
|
|
19
|
+
const drain = () => {
|
|
20
|
+
while (active < allowed()) {
|
|
21
|
+
const next = waiting.shift();
|
|
22
|
+
if (next === undefined)
|
|
23
|
+
return;
|
|
24
|
+
active++;
|
|
25
|
+
next();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
hold: async (work) => {
|
|
30
|
+
if (active < allowed())
|
|
31
|
+
active++;
|
|
32
|
+
else
|
|
33
|
+
await new Promise((resolve) => waiting.push(resolve));
|
|
34
|
+
try {
|
|
35
|
+
return await work();
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
active--;
|
|
39
|
+
drain();
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// The renders of a run that has no gate (a test, or an older wiring) go straight through.
|
|
45
|
+
export const openRenderGate = { hold: (work) => work() };
|