@anvpx/motion-build 0.1.94 → 0.1.95
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/audio/mix.d.ts +26 -10
- package/dist/audio/mix.js +64 -16
- package/dist/build.d.ts +15 -1
- package/dist/build.js +85 -16
- package/dist/emit/boot.d.ts +17 -2
- package/dist/emit/boot.js +31 -4
- package/dist/emit/boot.template.js +4 -4
- package/dist/emit/interaction-runtime.d.ts +11 -0
- package/dist/emit/interaction-runtime.js +121 -0
- package/dist/emit/vendor.d.ts +23 -0
- package/dist/emit/vendor.js +12 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lint/beat-variety.js +14 -8
- package/dist/lint/custom-source.d.ts +6 -0
- package/dist/lint/custom-source.js +201 -6
- package/dist/lint/index.js +3 -3
- package/dist/lint/visual-variety.d.ts +5 -0
- package/dist/lint/visual-variety.js +33 -10
- package/dist/templates/catalog-quality.d.ts +70 -0
- package/dist/templates/catalog-quality.js +221 -0
- package/dist/templates/index.d.ts +2 -1
- package/dist/templates/index.js +2 -1
- package/dist/templates/search.d.ts +11 -0
- package/dist/templates/search.js +12 -0
- package/dist/templates/validate.d.ts +2 -1
- package/dist/templates/validate.js +6 -23
- package/dist/validate-full.js +38 -45
- package/dist/validate-interaction.d.ts +7 -0
- package/dist/validate-interaction.js +32 -0
- package/dist/video/grain.d.ts +47 -0
- package/dist/video/grain.js +121 -0
- package/package.json +4 -4
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic raster grain that survives the H.264 delivery chain.
|
|
3
|
+
*
|
|
4
|
+
* HyperFrames writes the master picture; this module builds the ffmpeg argv for a
|
|
5
|
+
* single re-encode that bakes fixed-seed film grain into the pixels. It is a pure
|
|
6
|
+
* function of its inputs: no clock, no randomness, no environment. The mix and
|
|
7
|
+
* loudnorm steps copy the video stream, so grain applied here is present in the
|
|
8
|
+
* delivered mp4 unchanged.
|
|
9
|
+
*/
|
|
10
|
+
/** Fixed seed — the same frame always receives the same grain. */
|
|
11
|
+
export const GRAIN_SEED = 1337;
|
|
12
|
+
/** Subtle paper-tooth amplitude (noise `alls`): low enough not to read as TV snow. */
|
|
13
|
+
export const GRAIN_STRENGTH = 7;
|
|
14
|
+
/** The exact noise filter: uniform form with a per-frame temporal reseed, fixed seed. */
|
|
15
|
+
export const GRAIN_FILTER = `noise=alls=${GRAIN_STRENGTH}:allf=t+u:all_seed=${GRAIN_SEED}`;
|
|
16
|
+
/** Stable descriptor recorded in the render manifest (a code constant, not input). */
|
|
17
|
+
export const GRAIN_DESCRIPTOR = `noise:alls=${GRAIN_STRENGTH}:allf=t+u:seed=${GRAIN_SEED}`;
|
|
18
|
+
/** Intermediate written by the grain pass before it replaces the master. */
|
|
19
|
+
export const GRAIN_TEMP = "final-grain.mp4";
|
|
20
|
+
/** The optional delivery lens. `off` is the default and keeps today's exact bytes. */
|
|
21
|
+
export const LENS_OFF = "off";
|
|
22
|
+
export const LENS_FILM_HALO = "film-halo";
|
|
23
|
+
export const DEFAULT_LENS = LENS_OFF;
|
|
24
|
+
/*
|
|
25
|
+
* VISUAL-R1 §5.1 frozen highlight-halation graph. These stages are fixed constants,
|
|
26
|
+
* not tuned parameters: choosing one named preset before any render prevents
|
|
27
|
+
* post-hoc look-shopping. The same fixed-seed grain filter runs in both A/B arms.
|
|
28
|
+
*/
|
|
29
|
+
const HALO_SPLIT = "[0:v]split=2[base][halo]";
|
|
30
|
+
const HALO_MASK = `lutyuv=y='if(lt(val,168),0,(val-168)*255/87)'`;
|
|
31
|
+
const HALO_SPREAD = "gblur=sigma=14:steps=4";
|
|
32
|
+
const HALO_TINT = "colorchannelmixer=rr=1:gg=0.42:bb=0.22";
|
|
33
|
+
const HALO_REJOIN = "blend=all_mode=screen:all_opacity=0.22";
|
|
34
|
+
const HALO_FORMAT_IN = "format=yuv444p";
|
|
35
|
+
const HALO_FORMAT_OUT = "format=yuv420p";
|
|
36
|
+
/** The single frozen §5.1 filter_complex; the fixed noise filter is its last node. */
|
|
37
|
+
export const FILM_HALO_FILTER = [
|
|
38
|
+
HALO_SPLIT,
|
|
39
|
+
`[halo]${HALO_MASK},${HALO_SPREAD},${HALO_TINT},${HALO_FORMAT_IN}[haloPlate]`,
|
|
40
|
+
`[base]${HALO_FORMAT_IN}[basePlate]`,
|
|
41
|
+
`[basePlate][haloPlate]${HALO_REJOIN},${HALO_FORMAT_OUT}[blended]`,
|
|
42
|
+
`[blended]${GRAIN_FILTER}[out]`,
|
|
43
|
+
].join(";");
|
|
44
|
+
/** Manifest descriptor extended with the active lens: `off` stays byte-identical. */
|
|
45
|
+
export function grainDescriptor(lens = DEFAULT_LENS) {
|
|
46
|
+
return lens === LENS_OFF ? GRAIN_DESCRIPTOR : `${GRAIN_DESCRIPTOR}:lens=${lens}`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Builds the deterministic grain argv. Frame rate, frame count, duration, codec
|
|
50
|
+
* family and pixel format are preserved so `mk verify` / finalExpectation still
|
|
51
|
+
* pass. The encode is lossless (CRF 0): a lossy re-encode reconstructs the static
|
|
52
|
+
* fixed-seed grain with a different quantisation phase at each H.264 I-frame,
|
|
53
|
+
* reseeding the whole field by +/-1 LSB (the G-08 frame-500 pop). CRF 0 keeps
|
|
54
|
+
* I-frames and P-frames bit-identical; the tradeoff is a larger delivered mp4.
|
|
55
|
+
*
|
|
56
|
+
* `lens=off` (the default) is today's exact `-vf noise=` argv. `film-halo`
|
|
57
|
+
* replaces that single filter with the frozen §5.1 `filter_complex` inside this
|
|
58
|
+
* same ffmpeg invocation — one renderer, one encode, one source of truth.
|
|
59
|
+
*/
|
|
60
|
+
export function buildGrainArgs(input, output, fps, lens = DEFAULT_LENS) {
|
|
61
|
+
// `fps` is retained in the signature for call-site stability, but is intentionally
|
|
62
|
+
// not emitted: passthrough preserves the master's frame rate and timestamps exactly.
|
|
63
|
+
void fps;
|
|
64
|
+
const filter = lens === LENS_FILM_HALO
|
|
65
|
+
? ["-filter_complex", FILM_HALO_FILTER, "-map", "[out]"]
|
|
66
|
+
: ["-vf", GRAIN_FILTER];
|
|
67
|
+
return [
|
|
68
|
+
"-y",
|
|
69
|
+
"-i",
|
|
70
|
+
input,
|
|
71
|
+
...filter,
|
|
72
|
+
"-c:v",
|
|
73
|
+
"libx264",
|
|
74
|
+
"-preset",
|
|
75
|
+
"slow",
|
|
76
|
+
"-crf",
|
|
77
|
+
"0",
|
|
78
|
+
"-pix_fmt",
|
|
79
|
+
"yuv420p",
|
|
80
|
+
"-color_primaries",
|
|
81
|
+
"bt709",
|
|
82
|
+
"-color_trc",
|
|
83
|
+
"bt709",
|
|
84
|
+
"-colorspace",
|
|
85
|
+
"bt709",
|
|
86
|
+
// No -r here: ffmpeg 7 rejects -r together with a non-CFR -fps_mode.
|
|
87
|
+
// passthrough keeps the source's exact CFR timestamps, so fps needs no restatement.
|
|
88
|
+
"-fps_mode",
|
|
89
|
+
"passthrough",
|
|
90
|
+
"-threads",
|
|
91
|
+
"1",
|
|
92
|
+
"-movflags",
|
|
93
|
+
"+faststart",
|
|
94
|
+
"-an",
|
|
95
|
+
output,
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* High-pass energy of an 8-bit gray plane: mean squared deviation of each
|
|
100
|
+
* interior pixel from the average of its horizontal neighbours. A flat field is
|
|
101
|
+
* ~0; added grain raises it. Pure over the buffer — no I/O, no randomness.
|
|
102
|
+
*/
|
|
103
|
+
export function grainEnergy(gray, width) {
|
|
104
|
+
const height = Math.floor(gray.length / width);
|
|
105
|
+
if (width < 3 || height < 1)
|
|
106
|
+
return 0;
|
|
107
|
+
let energy = 0;
|
|
108
|
+
let count = 0;
|
|
109
|
+
for (let y = 0; y < height; y += 1) {
|
|
110
|
+
const row = y * width;
|
|
111
|
+
for (let x = 1; x < width - 1; x += 1) {
|
|
112
|
+
const center = gray[row + x] ?? 0;
|
|
113
|
+
const left = gray[row + x - 1] ?? 0;
|
|
114
|
+
const right = gray[row + x + 1] ?? 0;
|
|
115
|
+
const highPass = center - (left + right) / 2;
|
|
116
|
+
energy += highPass * highPass;
|
|
117
|
+
count += 1;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return count === 0 ? 0 : energy / count;
|
|
121
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anvpx/motion-build",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.95",
|
|
4
4
|
"description": "Storyboard compiler for @anvpx/motion: validation, scene emission and HyperFrames project output.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "anvpx",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"@fontsource/jetbrains-mono": "5.3.0",
|
|
32
32
|
"@fontsource/source-serif-4": "5.3.1",
|
|
33
33
|
"@fontsource/space-grotesk": "5.3.0",
|
|
34
|
-
"@anvpx/motion-scenes": "0.1.
|
|
35
|
-
"@anvpx/motion-schema": "0.1.
|
|
36
|
-
"@anvpx/motion-themes": "0.1.
|
|
34
|
+
"@anvpx/motion-scenes": "0.1.95",
|
|
35
|
+
"@anvpx/motion-schema": "0.1.95",
|
|
36
|
+
"@anvpx/motion-themes": "0.1.95",
|
|
37
37
|
"postprocessing": "6.39.5",
|
|
38
38
|
"three": "0.186.0"
|
|
39
39
|
},
|