rvlib-shipkit 2.17.1 → 2.19.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.
- package/CHANGELOG.md +27 -0
- package/package.json +1 -1
- package/src/asks/asks-queue.ts +63 -10
- package/src/checks/SK039-vscode-watch-generated.check.ts +119 -0
- package/src/cli/cmd_Asks.ts +3 -1
- package/src/cli/cmd_GlobalProcesses.ts +34 -11
- package/src/cli/cmd_Home.ts +38 -2
- package/src/cli/cmd_Secret.ts +4 -30
- package/src/cli/cmd_Social.ts +40 -1
- package/src/cli/cmd_Trailer.ts +15 -3
- package/src/cli/registry.ts +2 -1
- package/src/collections/actions.ts +29 -1
- package/src/collections/collection-types.ts +2 -0
- package/src/collections/providers.ts +1 -1
- package/src/home/home-paths.ts +5 -1
- package/src/home/home-start.ts +12 -12
- package/src/home/run-daemon.ts +11 -2
- package/src/home/run-pm.ts +9 -1
- package/src/home/supervise.ts +3 -1
- package/src/identities/identities.ts +22 -5
- package/src/review/http.ts +7 -2
- package/src/review/store.ts +81 -19
- package/src/scaffold/files/vscode-settings.json +9 -1
- package/src/secrets/manager.ts +59 -0
- package/src/secrets/name.ts +2 -0
- package/src/serve/hub-app/auto-text.tsx +6 -1
- package/src/serve/hub-app/col-card.tsx +10 -0
- package/src/serve/hub-app/cols-svc.ts +37 -6
- package/src/serve/hub-app/hub.css +1 -0
- package/src/serve/hub-app/review/review-st.ts +12 -2
- package/src/serve/hub-app/review/review-thread.tsx +1 -1
- package/src/serve/hub-app/review/thread-st.ts +17 -1
- package/src/serve/hub-app/social/identity-pictures.ts +74 -0
- package/src/serve/hub-app/social/kit.tsx +3 -3
- package/src/serve/hub-app/social/post-card.tsx +2 -1
- package/src/serve/hub-app/social/social-page.tsx +77 -37
- package/src/serve/hub-app/social.css +9 -4
- package/src/serve/hub-app/stores/stores-page.tsx +4 -3
- package/src/serve/hub-app/veille/veille-page.tsx +2 -1
- package/src/serve/serve-hub.ts +16 -6
- package/src/serve/warm-cell.ts +63 -1
- package/src/shot/box.ts +23 -8
- package/src/shot/browser-slot.ts +8 -1
- package/src/shot/client.ts +9 -4
- package/src/shot/clip-encoder.ts +5 -2
- package/src/shot/job-store.ts +167 -0
- package/src/shot/shooter.ts +8 -3
- package/src/social/discord-layout.ts +239 -0
- package/src/social/md.ts +14 -6
- package/src/social/publish/discord.ts +3 -2
- package/src/social/routes.ts +3 -3
- package/src/stores/routes.ts +2 -2
- package/src/suite/judge-suites.ts +1 -1
- package/src/suite/select.ts +32 -6
- package/src/suite/suite-cli.ts +5 -5
- package/src/trailer/build.ts +75 -50
- package/src/trailer/draft.ts +28 -0
- package/src/trailer/footage.ts +4 -2
- package/src/trailer/grammar.ts +11 -9
- package/src/trailer/graph.ts +41 -12
- package/src/trailer/profile.ts +35 -0
- package/src/trailer/prune.ts +15 -10
- package/src/trailer/stitch.ts +22 -10
- package/src/trailer/titles.ts +47 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// a cut's draft (`sk trailer --draft`): the same cut, smaller and quicker, to judge its beats. It reads every take the
|
|
2
|
+
// cut has filmed as it is and films a missing one small, under a key of its own (a take's key holds its size), so a
|
|
3
|
+
// draft take never stands in a full build or a kept version. Its rate stays the cut's: every take decodes each of its
|
|
4
|
+
// frames anyway, and a rate converted down made the stitch slower (8.3 s at 30 fps, 11.9 s at 15 on a 74 s cut). Its
|
|
5
|
+
// sound is the cut's own mix, its pieces render under `<name>-draft-<section>`, its mp4 is `out/<name>-draft.mp4`
|
|
6
|
+
import { type Refilm, type Take, takesToFilm, type World } from './plan.ts'
|
|
7
|
+
import type { Trailer } from './grammar.ts'
|
|
8
|
+
|
|
9
|
+
/** how a draft is smaller than its cut: each side scaled */
|
|
10
|
+
export interface Draft {
|
|
11
|
+
scale: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const DRAFT: Draft = { scale: 0.5 }
|
|
15
|
+
|
|
16
|
+
/** the name a draft's pieces, takes and mp4 go under */
|
|
17
|
+
export const draftName = (name: string): string => `${name}-draft`
|
|
18
|
+
|
|
19
|
+
/** the cut as its draft draws it: its size scaled (even sides, as H.264 takes), its own name */
|
|
20
|
+
export function draftOf<T extends Pick<Trailer, 'name' | 'size'>>(t: T, d: Draft = DRAFT): T {
|
|
21
|
+
const even = (x: number): number => Math.max(2, 2 * Math.round((x * d.scale) / 2))
|
|
22
|
+
return { ...t, name: draftName(t.name), size: [even(t.size[0]), even(t.size[1])] }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** the takes a draft reads: the cut's own wherever it has one the build would not film again, else the draft's */
|
|
26
|
+
export function draftTakes(full: readonly Take[], small: readonly Take[], world: World, refilm: Refilm): Take[] {
|
|
27
|
+
return full.map((tk, i) => (takesToFilm([tk], world, refilm).length === 0 ? tk : small[i]!))
|
|
28
|
+
}
|
package/src/trailer/footage.ts
CHANGED
|
@@ -122,6 +122,8 @@ export interface FilmContext {
|
|
|
122
122
|
cli: readonly string[] | null
|
|
123
123
|
/** a clip take that drops its picture is filmed again once, then refused (the unit's `holes`) */
|
|
124
124
|
holes?: boolean
|
|
125
|
+
/** a draft's take (draft.ts): `t` is the draft's size and rate, and the row is told so */
|
|
126
|
+
draft?: boolean
|
|
125
127
|
say: (line: string) => void
|
|
126
128
|
}
|
|
127
129
|
|
|
@@ -167,8 +169,8 @@ export async function filmTake(tk: Take, c: FilmContext): Promise<Take> {
|
|
|
167
169
|
async function commandTake(tk: Take, f: Exclude<TakeFilm, { kind: 'url' | 'page' }>, part: string, seconds: number | null, c: FilmContext): Promise<string> {
|
|
168
170
|
if (f.kind === 'cli' && c.cli === null) throw new Error(`shot ${tk.shot.name} (line ${f.line}): film ${f.argv.join(' ')} needs the project CLI (the cli script of package.json)`)
|
|
169
171
|
const argv = f.kind === 'run' ? ['sh', '-c', runCommand(f, { out: part, seconds, size: c.t.size, fps: c.t.fps })] : cliArgv(c.cli!, f, part, seconds, tk.argv)
|
|
170
|
-
// the cut's frame and rate: a row that films at the cut's size reads them
|
|
171
|
-
const env = { ...process.env, SK_TRAILER_SIZE: `${c.t.size[0]}x${c.t.size[1]}`, SK_TRAILER_FPS: String(c.t.fps) }
|
|
172
|
+
// the cut's frame and rate: a row that films at the cut's size reads them; a draft's row may film smaller and quicker
|
|
173
|
+
const env = { ...process.env, SK_TRAILER_SIZE: `${c.t.size[0]}x${c.t.size[1]}`, SK_TRAILER_FPS: String(c.t.fps), ...(c.draft ? { SK_TRAILER_DRAFT: '1' } : {}) }
|
|
172
174
|
const p = Bun.spawn(argv, { cwd: c.root, stdout: 'pipe', stderr: 'pipe', env })
|
|
173
175
|
const [out, err, code] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text(), p.exited])
|
|
174
176
|
const said = `${out}${err}`.trim()
|
package/src/trailer/grammar.ts
CHANGED
|
@@ -147,8 +147,8 @@ export interface Title {
|
|
|
147
147
|
/** null: to the shot's end */
|
|
148
148
|
for: number | null
|
|
149
149
|
style: TitleStyle
|
|
150
|
-
/** where a caption sits: the bottom by default */
|
|
151
|
-
place?:
|
|
150
|
+
/** where a caption sits: the bottom by default; `middle` centres a big title on both axes */
|
|
151
|
+
place?: TitlePlace
|
|
152
152
|
/** knocked off the frame from this second of its shot: it tips and flies out */
|
|
153
153
|
knock?: number
|
|
154
154
|
/** a `progress` line's step: the i-th of n notches filled under its name */
|
|
@@ -186,18 +186,20 @@ export interface TitleFx {
|
|
|
186
186
|
glow?: { px: number; color?: string }
|
|
187
187
|
/** the widest share of the frame's width the word takes */
|
|
188
188
|
fit?: number
|
|
189
|
-
/** the subtitle's height to the word's */
|
|
189
|
+
/** the subtitle's height to the word's (a big title: its lines after the first break, to the first's) */
|
|
190
190
|
sub?: number
|
|
191
191
|
/** the space between the word and its subtitle, a share of the word's height */
|
|
192
192
|
gap?: number
|
|
193
193
|
/** the word's middle at this share of the frame's height (default: the whole block's middle at 0.48) */
|
|
194
194
|
middle?: number
|
|
195
|
-
/** the soft shade round the logo, its radius a share of the frame's longer side; 0 for none
|
|
195
|
+
/** the soft shade round the logo, its radius a share of the frame's longer side; 0 for none (a big title: a scrim
|
|
196
|
+
* round its words, its alpha at the middle, so they read over a busy picture) */
|
|
196
197
|
shade?: number
|
|
197
198
|
}
|
|
198
199
|
|
|
199
|
-
/** the look words only a logo title reads */
|
|
200
|
+
/** the look words only a logo title reads, `sub` and `shade` a big title too */
|
|
200
201
|
export const LOGO_WORDS = ['fit', 'sub', 'gap', 'middle', 'shade'] as const
|
|
202
|
+
const BIG_TOO: readonly string[] = ['sub', 'shade']
|
|
201
203
|
|
|
202
204
|
/** how a made sound is made (design call 9): its seed, the voice or engine it is made `by`, its length (`for`), an sfx
|
|
203
205
|
* trimmed to its first `hit` */
|
|
@@ -566,7 +568,7 @@ const TITLE_WORDS: Record<string, (w: Word | undefined, k: string) => unknown> =
|
|
|
566
568
|
for: (w, k) => time(k, w),
|
|
567
569
|
place: (w, k) => {
|
|
568
570
|
const pl = word(k, w)
|
|
569
|
-
return pl === 'top' || pl === 'bottom' ? pl : bad(`${k} wants top|bottom, got ${pl}`)
|
|
571
|
+
return pl === 'top' || pl === 'middle' || pl === 'bottom' ? pl : bad(`${k} wants top|middle|bottom, got ${pl}`)
|
|
570
572
|
},
|
|
571
573
|
knock: (w, k) => time(k, w),
|
|
572
574
|
font: (w, k) => pathWord(k, w),
|
|
@@ -636,7 +638,7 @@ const fxOf = (v: Record<string, unknown>): TitleFx => Object.fromEntries(FX_WORD
|
|
|
636
638
|
const builtInStyle = (st: string): st is TitleStyle => (TITLE_STYLES as readonly string[]).includes(st)
|
|
637
639
|
/** a logo word on a title of another style fails: nothing would read it */
|
|
638
640
|
const logoOnly = (style: TitleStyle, fx: TitleFx | undefined): void => {
|
|
639
|
-
const odd = LOGO_WORDS.filter((w) => fx?.[w] !== undefined)
|
|
641
|
+
const odd = LOGO_WORDS.filter((w) => fx?.[w] !== undefined && !(style === 'big' && BIG_TOO.includes(w)))
|
|
640
642
|
if (style !== 'logo' && odd.length > 0) bad(`title ${odd.join(', ')}: a logo's words, this title is ${style}`)
|
|
641
643
|
}
|
|
642
644
|
|
|
@@ -673,7 +675,7 @@ export function resolveStyles(t: Pick<Trailer, 'shots'>, styles: Readonly<Record
|
|
|
673
675
|
const fx = { ...fxOf(under), ...ti.fx }
|
|
674
676
|
logoOnly(ti.style, fx)
|
|
675
677
|
if (Object.keys(fx).length > 0) ti.fx = fx
|
|
676
|
-
if (under.place && !ti.place) ti.place = under.place as
|
|
678
|
+
if (under.place && !ti.place) ti.place = under.place as TitlePlace
|
|
677
679
|
if (under.in && !ti.in) ti.in = under.in as Move
|
|
678
680
|
if (under.out && !ti.out && ti.knock === undefined) ti.out = under.out as Move
|
|
679
681
|
} catch (e) {
|
|
@@ -1379,7 +1381,7 @@ export function parseTrailer(text: string, o: ParseOptions = {}): { trailer: Tra
|
|
|
1379
1381
|
// a brand style is laid in by resolveStyles, once the brand is read
|
|
1380
1382
|
style: builtInStyle(st) ? st : 'caption',
|
|
1381
1383
|
...(builtInStyle(st) ? {} : { named: st }),
|
|
1382
|
-
...(p.place ? { place: p.place as
|
|
1384
|
+
...(p.place ? { place: p.place as TitlePlace } : {}),
|
|
1383
1385
|
...(p.knock !== undefined ? { knock: p.knock as number } : {}),
|
|
1384
1386
|
...(p.in ? { in: p.in as Move } : {}),
|
|
1385
1387
|
...(p.out ? { out: p.out as Move } : {}),
|
package/src/trailer/graph.ts
CHANGED
|
@@ -54,6 +54,14 @@ export interface StitchInput {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const n3 = (x: number): string => (+x.toFixed(4)).toString()
|
|
57
|
+
|
|
58
|
+
/** a shot's slow push in, from whole to `push` over its `frames`, centred: sampled at sub pixel positions (perspective,
|
|
59
|
+
* cubic), where zoompan's crop steps by whole pixels, so a slow push held still for frames, then jumped */
|
|
60
|
+
export function pushFilter(push: number, frames: number, skip: number, [W, H]: readonly [number, number]): string {
|
|
61
|
+
const z = `(1+${n3(push - 1)}*(in+${skip})/${frames})`
|
|
62
|
+
const [x0, x1, y0, y1] = [`W/2*(1-1/${z})`, `W/2*(1+1/${z})`, `H/2*(1-1/${z})`, `H/2*(1+1/${z})`]
|
|
63
|
+
return `,scale=${W}:${H},perspective=x0='${x0}':y0='${y0}':x1='${x1}':y1='${y0}':x2='${x0}':y2='${y1}':x3='${x1}':y3='${y1}':interpolation=cubic:eval=frame`
|
|
64
|
+
}
|
|
57
65
|
const even = (x: number): number => 2 * Math.round(x / 2)
|
|
58
66
|
|
|
59
67
|
/** the grid's margin round the cells and the gap between them, and the corners' radius, in frame heights */
|
|
@@ -312,9 +320,7 @@ export function pieceArgs(a: Pick<StitchInput, 't' | 'sources' | 'titles' | 'loo
|
|
|
312
320
|
const frames = Math.min(spans[i]!.b, p.to) - spans[i]!.a - skip
|
|
313
321
|
count[i] = frames
|
|
314
322
|
const push = s.push && s.push > 1 ? s.push : null
|
|
315
|
-
const pushF = push
|
|
316
|
-
? `,scale=${W * 2}:${H * 2},zoompan=z='1+${n3(push - 1)}*(on+${skip})/${Math.round(len * fps)}':x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)':d=1:s=${W}x${H}:fps=${fps}`
|
|
317
|
-
: ''
|
|
323
|
+
const pushF = push ? pushFilter(push, Math.round(len * fps), skip, [W, H]) : ''
|
|
318
324
|
const [ax, ay] = s.frameAt ?? [0.5, 0.5]
|
|
319
325
|
const cropF = s.frame && s.frame > 1 ? `crop=w='2*trunc(iw/${n3(s.frame)}/2)':h='2*trunc(ih/${n3(s.frame)}/2)':x='min(max(iw*${n3(ax)}-ow/2,0),iw-ow)':y='min(max(ih*${n3(ay)}-oh/2,0),ih-oh)'` : null
|
|
320
326
|
const frameF = cropF ? `,${cropF},scale=${W}:${H}` : ''
|
|
@@ -523,16 +529,39 @@ export interface MixLevel {
|
|
|
523
529
|
/** how close a mix lands to its `master`, LU */
|
|
524
530
|
export const MASTER_TOLERANCE = 0.3
|
|
525
531
|
|
|
526
|
-
/**
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
532
|
+
/** one pass of the mix: its level and what ebur128 measured of it */
|
|
533
|
+
export interface MixPass {
|
|
534
|
+
level: MixLevel
|
|
535
|
+
m: { lufs: number; truePeak: number }
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/** a dB of gain moves the loudness by less once the limiter takes the peaks it raises: this much at least */
|
|
539
|
+
const MIN_SLOPE = 0.25
|
|
540
|
+
|
|
541
|
+
/** the level of the mix's next pass, from the passes so far (the last one last); null: it holds. Over the ceiling, the
|
|
542
|
+
* trim drops by the overshoot. Off its master, the gain moves by the gap that trim leaves (it lowers the loudness dB
|
|
543
|
+
* for dB), over how much a dB of gain moved the loudness between the last two gains (1 before a second gain). The
|
|
544
|
+
* gaps are rounded to ebur128's tenth, so a mix measured on the tolerance holds */
|
|
545
|
+
export function nextMixLevel(master: number | null, passes: readonly MixPass[]): MixLevel | null {
|
|
546
|
+
const { level, m } = passes.at(-1)!
|
|
547
|
+
const over = +(m.truePeak - MIX_TRUE_PEAK).toFixed(2)
|
|
548
|
+
const gap = master === null ? 0 : +(master - m.lufs).toFixed(2)
|
|
531
549
|
if (over <= 0 && Math.abs(gap) <= MASTER_TOLERANCE) return null
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
550
|
+
const trim = over > 0 ? +(level.trim - over - 0.1).toFixed(2) : level.trim
|
|
551
|
+
const left = +(gap - (trim - level.trim)).toFixed(2)
|
|
552
|
+
if (master === null || Math.abs(left) <= MASTER_TOLERANCE) return { gain: level.gain, trim }
|
|
553
|
+
const before = passes.findLast((p) => p.level.gain !== level.gain)
|
|
554
|
+
const moved = before ? (m.lufs - level.trim - (before.m.lufs - before.level.trim)) / (level.gain - before.level.gain) : 1
|
|
555
|
+
const slope = Math.min(1, Math.max(MIN_SLOPE, moved))
|
|
556
|
+
return { gain: +(level.gain + left / slope).toFixed(2), trim }
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/** the pass a mix that never held keeps: under the ceiling and nearest its master, else the lowest peak */
|
|
560
|
+
export function bestMixPass<P extends MixPass>(master: number | null, passes: readonly P[]): P {
|
|
561
|
+
const under = passes.filter((p) => +(p.m.truePeak - MIX_TRUE_PEAK).toFixed(2) <= 0)
|
|
562
|
+
const off = (p: MixPass): number => (master === null ? 0 : Math.abs(master - p.m.lufs))
|
|
563
|
+
if (under.length > 0) return under.reduce((a, b) => (off(b) < off(a) ? b : a))
|
|
564
|
+
return passes.reduce((a, b) => (b.m.truePeak < a.m.truePeak ? b : a))
|
|
536
565
|
}
|
|
537
566
|
|
|
538
567
|
/** the ffmpeg arguments that mix the cut's sound: the music trimmed, faded and ducked under each voice line, the sfx
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// a build's phases on one clock, for `sk trailer --profile`: each span its name, its start and its length since the
|
|
2
|
+
// process started. A few performance.now calls a phase, so always recorded, printed only when asked. Spans that run
|
|
3
|
+
// side by side (the takes, the sections, the mix) overlap: their shares sum past 100 %
|
|
4
|
+
export interface Span {
|
|
5
|
+
name: string
|
|
6
|
+
at: number
|
|
7
|
+
ms: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const spans: Span[] = []
|
|
11
|
+
|
|
12
|
+
/** `fn` timed under `name` */
|
|
13
|
+
export async function timed<T>(name: string, fn: () => Promise<T> | T): Promise<T> {
|
|
14
|
+
const at = performance.now()
|
|
15
|
+
try {
|
|
16
|
+
return await fn()
|
|
17
|
+
} finally {
|
|
18
|
+
spans.push({ name, at, ms: performance.now() - at })
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** a span measured by its caller: the process's own start, before any module of the build loaded */
|
|
23
|
+
export const span = (name: string, at: number, ms: number): void => void spans.push({ name, at, ms })
|
|
24
|
+
|
|
25
|
+
/** every span by its start, its seconds and its share of the whole run, then the whole run */
|
|
26
|
+
export function profileLines(): string[] {
|
|
27
|
+
const wall = performance.now()
|
|
28
|
+
const s = (ms: number): string => (ms / 1000).toFixed(2).padStart(7)
|
|
29
|
+
const w = Math.max(5, ...spans.map((x) => x.name.length))
|
|
30
|
+
return [
|
|
31
|
+
`profile: ${'phase'.padEnd(w)} start seconds share`,
|
|
32
|
+
...[...spans].sort((a, b) => a.at - b.at).map((x) => `profile: ${x.name.padEnd(w)} ${s(x.at)} ${s(x.ms)} ${((100 * x.ms) / wall).toFixed(0).padStart(4)} %`),
|
|
33
|
+
`profile: ${'the whole run'.padEnd(w)} ${s(0)} ${s(wall)} 100 %`,
|
|
34
|
+
]
|
|
35
|
+
}
|
package/src/trailer/prune.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface Live {
|
|
|
29
29
|
/** the live set: each cut read, the name of every cache file its build reads, by the build's own key functions */
|
|
30
30
|
export async function liveSet(root: string): Promise<Live> {
|
|
31
31
|
const live: Live = { footage: new Set(), stems: new Set(), sound: new Set(), score: new Set(), titles: new Set(), broken: [] }
|
|
32
|
-
const [{ fileOf,
|
|
32
|
+
const [{ fileOf, titleRequest }, { trailerCache, takesOf }, { scoreWavFile }, { scoreModuleFile, scoreModule }, titles, { lookOf }, { loadBrand, identityLogo }, fonts, { titleMotions }, { resolveStyles }, { draftOf }] = await Promise.all([
|
|
33
33
|
import('./build.ts'),
|
|
34
34
|
import('./footage.ts'),
|
|
35
35
|
import('./score/sound.ts'),
|
|
@@ -40,6 +40,7 @@ export async function liveSet(root: string): Promise<Live> {
|
|
|
40
40
|
import('./fonts.ts'),
|
|
41
41
|
import('./graph.ts'),
|
|
42
42
|
import('./grammar.ts'),
|
|
43
|
+
import('./draft.ts'),
|
|
43
44
|
])
|
|
44
45
|
const brand = await loadBrand(root)
|
|
45
46
|
const look = typeof brand === 'string' ? null : lookOf(brand, await identityLogo(root))
|
|
@@ -53,19 +54,23 @@ export async function liveSet(root: string): Promise<Live> {
|
|
|
53
54
|
continue
|
|
54
55
|
}
|
|
55
56
|
const t = l.t
|
|
56
|
-
const names = { footage:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
const names = { footage: [] as string[], stems: [`mix-${t.name}`] as string[], titles: [] as string[], score: [] as string[], sound: [] as string[] }
|
|
58
|
+
// the cut and its draft (draft.ts), each its takes, pieces and titles; the draft plays the cut's mix
|
|
59
|
+
for (const lv of [l, { ...l, t: draftOf(t) }]) {
|
|
60
|
+
const tv = lv.t
|
|
61
|
+
names.footage.push(...takesOf(tv, root, l).map((tk) => basename(tk.file)))
|
|
62
|
+
for (const p of pieces(tv)) names.stems.push(`${tv.name}-${p.name}`)
|
|
63
|
+
names.stems.push(`${tv.name}-vertical`)
|
|
64
|
+
if (!look) continue
|
|
60
65
|
const dir = trailerCache(root, 'titles')
|
|
61
|
-
names.titles.push(basename(titles.cardFile(dir,
|
|
62
|
-
resolveStyles(
|
|
63
|
-
const motions = titleMotions(
|
|
64
|
-
|
|
66
|
+
names.titles.push(basename(titles.cardFile(dir, tv.size, look)))
|
|
67
|
+
resolveStyles(tv, (typeof brand === 'object' && brand?.trailer?.styles) || {})
|
|
68
|
+
const motions = titleMotions(tv)
|
|
69
|
+
tv.shots.forEach((s, i) =>
|
|
65
70
|
s.titles.forEach((ti, j) => {
|
|
66
71
|
const f = ti.fx?.font
|
|
67
72
|
const font = f === undefined ? null : fonts.isFontFile(f) ? fileOf(f, l) : fonts.googleFile(f, ti.fx?.weight ?? 400)
|
|
68
|
-
names.titles.push(basename(titles.titleFile(dir, { ...titleRequest(
|
|
73
|
+
names.titles.push(basename(titles.titleFile(dir, { ...titleRequest(lv, ti, look, motions[i]![j]!), font })))
|
|
69
74
|
}),
|
|
70
75
|
)
|
|
71
76
|
}
|
package/src/trailer/stitch.ts
CHANGED
|
@@ -6,9 +6,10 @@ import { availableParallelism } from 'node:os'
|
|
|
6
6
|
import { dirname, join } from 'node:path'
|
|
7
7
|
import sharp from 'sharp'
|
|
8
8
|
import { ffmpeg, loudnessKept } from './ffmpeg.ts'
|
|
9
|
-
import { type Encoder, GRID_RADIUS, gridLayout, type MixLevel, mixArgs, nextMixLevel, pieceArgs, type SplitMasks, splitPane, type StitchInput, THUMB_W } from './graph.ts'
|
|
9
|
+
import { bestMixPass, type Encoder, GRID_RADIUS, gridLayout, type MixLevel, type MixPass, mixArgs, nextMixLevel, pieceArgs, type SplitMasks, splitPane, type StitchInput, THUMB_W } from './graph.ts'
|
|
10
10
|
import type { TrailerLook } from './look.ts'
|
|
11
11
|
import { type Piece, pieces, twinStem } from './plan.ts'
|
|
12
|
+
import { timed } from './profile.ts'
|
|
12
13
|
|
|
13
14
|
/** bump when the stitch changes what the same arguments make */
|
|
14
15
|
const STITCH_VERSION = 1
|
|
@@ -182,13 +183,18 @@ export interface StitchRun extends StitchInput {
|
|
|
182
183
|
encoder?: Encoder
|
|
183
184
|
/** no sound at all: a shot's preview */
|
|
184
185
|
silent?: boolean
|
|
186
|
+
/** the mix its caller started (renderMix of the same sounds), awaited in place of mixing again */
|
|
187
|
+
mixing?: ReturnType<typeof renderMix>
|
|
188
|
+
/** each piece draws its row of the strip (default); false: none, `thumbs` empty */
|
|
189
|
+
thumbs?: boolean
|
|
185
190
|
}
|
|
186
191
|
|
|
187
192
|
async function renderPieces(a: StitchRun, ps: Piece[]): Promise<Stitched['pieces']> {
|
|
193
|
+
const exts = a.thumbs === false ? ['mp4'] : ['mp4', 'png']
|
|
188
194
|
return pool(
|
|
189
195
|
ps.map((p) => async () => {
|
|
190
|
-
const { files, made, twin, key } = await cached(a.cache, `${a.t.name}-${p.name}`,
|
|
191
|
-
return { ...p, made, key, ...(twin !== undefined ? { twin } : {}), file: files[0]!, thumbs: files[1]
|
|
196
|
+
const { files, made, twin, key } = await timed(`section ${p.name}`, () => cached(a.cache, `${a.t.name}-${p.name}`, exts, ([video, row]) => pieceArgs(a, p, video!, a.encoder, row)))
|
|
197
|
+
return { ...p, made, key, ...(twin !== undefined ? { twin } : {}), file: files[0]!, thumbs: files[1] ?? '' }
|
|
192
198
|
}),
|
|
193
199
|
LANES,
|
|
194
200
|
)
|
|
@@ -196,16 +202,22 @@ async function renderPieces(a: StitchRun, ps: Piece[]): Promise<Stitched['pieces
|
|
|
196
202
|
|
|
197
203
|
/** the mix, its true peak held under MIX_TRUE_PEAK after the aac encode (the encoder's band limit rings over a limited
|
|
198
204
|
* harsh sound: a square wave measured +2.1 dB), and with a `master` its integrated loudness on it: each pass measured
|
|
199
|
-
* as ebur128 hears it, then made again at the level nextMixLevel says, every pass kept in the cache
|
|
205
|
+
* as ebur128 hears it, then made again at the level nextMixLevel says, every pass kept in the cache; a mix that never
|
|
206
|
+
* holds keeps its best pass (bestMixPass) */
|
|
200
207
|
export async function renderMix(a: Pick<StitchRun, 't' | 'music' | 'sfx' | 'voices' | 'cache'>): Promise<{ file: string; key: string; made: boolean; twin?: string }> {
|
|
201
|
-
const
|
|
208
|
+
const cap = a.t.master === null ? 3 : 6
|
|
209
|
+
const passes: (MixPass & { r: Render })[] = []
|
|
202
210
|
let level: MixLevel = { gain: 0, trim: 0 }
|
|
203
211
|
let made = false
|
|
204
212
|
for (let pass = 1; ; pass++) {
|
|
205
|
-
const r = await cached(join(a.cache, 'mix'), `mix-${a.t.name}`, ['m4a'], ([out]) => mixArgs(a, out!, level))
|
|
213
|
+
const r = await timed(`mix pass ${pass}`, () => cached(join(a.cache, 'mix'), `mix-${a.t.name}`, ['m4a'], ([out]) => mixArgs(a, out!, level)))
|
|
206
214
|
made ||= r.made
|
|
207
|
-
|
|
208
|
-
|
|
215
|
+
passes.push({ level, m: await timed(`mix pass ${pass} measured`, () => loudnessKept(r.files[0]!)), r })
|
|
216
|
+
const next = nextMixLevel(a.t.master, passes)
|
|
217
|
+
if (next === null || pass === cap) {
|
|
218
|
+
const kept = next === null ? r : bestMixPass(a.t.master, passes).r
|
|
219
|
+
return { file: kept.files[0]!, key: kept.key, made, ...(kept.twin !== undefined && !made ? { twin: kept.twin } : {}) }
|
|
220
|
+
}
|
|
209
221
|
level = next
|
|
210
222
|
}
|
|
211
223
|
}
|
|
@@ -230,8 +242,8 @@ async function joinPieces(files: string[], sound: { file: string; start?: number
|
|
|
230
242
|
|
|
231
243
|
/** the whole cut: every piece (rendered where the cache misses it), joined, with its sound */
|
|
232
244
|
export async function stitch(a: StitchRun): Promise<Stitched> {
|
|
233
|
-
const [ps, mix] = await Promise.all([renderPieces(a, pieces(a.t)), a.silent ? null : renderMix(a)])
|
|
234
|
-
await joinPieces(ps.map((p) => p.file), mix ? { file: mix.file } : null, a.out)
|
|
245
|
+
const [ps, mix] = await Promise.all([renderPieces(a, pieces(a.t)), a.silent ? null : (a.mixing ?? renderMix(a))])
|
|
246
|
+
await timed('join', () => joinPieces(ps.map((p) => p.file), mix ? { file: mix.file } : null, a.out))
|
|
235
247
|
return { pieces: ps, ...mixOf(mix) }
|
|
236
248
|
}
|
|
237
249
|
|
package/src/trailer/titles.ts
CHANGED
|
@@ -86,6 +86,20 @@ interface Ctx {
|
|
|
86
86
|
const restCtx = (): Ctx => ({ n: 0, i: 0, decor: 1 })
|
|
87
87
|
|
|
88
88
|
/** a plate, a band, a glow or the logo image: faded with the title's decor */
|
|
89
|
+
/** a paint at `s` times its size, every stroke and blur with it */
|
|
90
|
+
function scaled(p: Paint, s: number): Paint {
|
|
91
|
+
return {
|
|
92
|
+
...p,
|
|
93
|
+
px: p.px * s,
|
|
94
|
+
spacing: p.spacing * s,
|
|
95
|
+
drop: p.drop ? { ...p.drop, dy: p.drop.dy * s } : (p.drop ?? null),
|
|
96
|
+
outline: p.outline ? { ...p.outline, w: p.outline.w * s, ...(p.outline.dy !== undefined ? { dy: p.outline.dy * s } : {}) } : null,
|
|
97
|
+
inner: p.inner ? { ...p.inner, w: p.inner.w * s } : null,
|
|
98
|
+
shadow: p.shadow ? { ...p.shadow, blur: p.shadow.blur * s, dy: p.shadow.dy * s } : null,
|
|
99
|
+
glow: p.glow ? { ...p.glow, blur: p.glow.blur * s } : null,
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
89
103
|
function decor(cx: Ctx, g: SKRSContext2D, draw: () => void): void {
|
|
90
104
|
g.save()
|
|
91
105
|
g.globalAlpha *= cx.decor
|
|
@@ -400,9 +414,40 @@ function drawInto(g: SKRSContext2D, d: TitleDraw, [W, H]: readonly [number, numb
|
|
|
400
414
|
} else if (style === 'big') {
|
|
401
415
|
// a strong display line in the upper third: light words in a thick edge outline, an accent stroke inside it
|
|
402
416
|
const p = own({ ...base((d.fx?.size ?? 112) * k, 900), outline: { w: 22 * k, color: look.edge }, inner: { w: 8 * k, color: look.accent }, shadow: { blur: 26 * k, dy: 10 * k, color: alpha(look.edge, 0.55) } })
|
|
417
|
+
// `place middle` centres the block on both axes; `sub` draws the lines after the first break that much smaller,
|
|
418
|
+
// `shade` lays a soft dark ellipse round the words (its alpha at the middle) so they read over a busy picture
|
|
419
|
+
const fx = d.fx
|
|
420
|
+
const small = fx?.sub !== undefined && more.length > 0 ? scaled(p, fx.sub) : null
|
|
403
421
|
setFace(g, p)
|
|
404
|
-
const
|
|
405
|
-
|
|
422
|
+
const rows: { l: string; p: Paint }[] = (small ? wrap(g, first, W * 0.82) : wrap(g, text, W * 0.82)).map((l) => ({ l, p }))
|
|
423
|
+
if (small) {
|
|
424
|
+
setFace(g, small)
|
|
425
|
+
rows.push(...wrap(g, more.join('\\n'), W * 0.82).map((l) => ({ l, p: small })))
|
|
426
|
+
}
|
|
427
|
+
const block = rows.reduce((s, r) => s + r.p.px * 1.12, 0)
|
|
428
|
+
const cy = d.place === 'middle' ? H * 0.5 : H * 0.26
|
|
429
|
+
if (fx?.shade)
|
|
430
|
+
decor(cx, g, () => {
|
|
431
|
+
const wide = Math.max(...rows.map((r) => (setFace(g, r.p), g.measureText(r.l.replaceAll('*', '')).width)))
|
|
432
|
+
const [rx, ry] = [wide / 2 + 160 * k, block / 2 + 110 * k]
|
|
433
|
+
g.save()
|
|
434
|
+
g.translate(W / 2, cy)
|
|
435
|
+
g.scale(rx / ry, 1)
|
|
436
|
+
const a = Math.min(1, fx.shade!)
|
|
437
|
+
const s = g.createRadialGradient(0, 0, 0, 0, 0, ry)
|
|
438
|
+
s.addColorStop(0, alpha(look.edge, a))
|
|
439
|
+
s.addColorStop(0.55, alpha(look.edge, a * 0.75))
|
|
440
|
+
s.addColorStop(1, alpha(look.edge, 0))
|
|
441
|
+
g.fillStyle = s
|
|
442
|
+
g.fillRect(-ry, -ry, ry * 2, ry * 2)
|
|
443
|
+
g.restore()
|
|
444
|
+
})
|
|
445
|
+
let y = cy - block / 2
|
|
446
|
+
for (const r of rows) {
|
|
447
|
+
setFace(g, r.p)
|
|
448
|
+
ink(cx, g, r.p, r.l, W / 2, y + (r.p.px * 1.12) / 2)
|
|
449
|
+
y += r.p.px * 1.12
|
|
450
|
+
}
|
|
406
451
|
} else if (style === 'line') {
|
|
407
452
|
// a tagline: light words centred low on a soft dark band, no plate, the frame stays the picture
|
|
408
453
|
const p = own({ ...base((d.fx?.size ?? 64) * k, look.font.weight), outline: { w: 9 * k, color: alpha(look.edge, 0.82) }, shadow: { blur: 18 * k, dy: 4 * k, color: alpha(look.edge, 0.85) } })
|