@aicopycoders/exodus 2026.9.1100-beta.0 → 2026.9.1100-beta.1
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/assets/docs/CLAUDE.md
CHANGED
|
@@ -61,6 +61,7 @@ These are the **Exodus** pipelines — the automatic system that drives the Gene
|
|
|
61
61
|
| **Meme** | `exodus-meme` | Meme ads — recommends formats for a brief, then one batched run renders AI-image and classic Imgflip-template memes server-side. |
|
|
62
62
|
| **Workflow** | `exodus-workflow` | Run and build saved multi-node workflow automations from the CLI, resolve checkpoint/repair parks from the inbox, continue bot sessions, fire triggers, and read banks or promote winners. |
|
|
63
63
|
| **Hooks** | `exodus-hooks` | Read the Scout library — the hook cards captured from Instagram outliers. Compose filters (score, lane, validation status, language, hook type, recency), inspect one card, find cards sharing a hook pattern, export to CSV. Read-only. |
|
|
64
|
+
| **Video** | `exodus-video` | Make a video ad from a Show: start a run from a script, read and approve the storyboard, `npx @aicopycoders/exodus video pull` every piece (per-scene clips, voices, keyframes, word timings, music bed) plus a manifest, cut them with the bundled first-cut script, upload the cut and approve it. Admin-only. |
|
|
64
65
|
| **Browse** | `exodus-browse` | View history and retrieve past outputs |
|
|
65
66
|
| **Drive** | `exodus-drive` | Read/write Google Docs, Sheets, and Drive files via `npx @aicopycoders/exodus drive` (uses the dashboard's Google OAuth — no local CLI) |
|
|
66
67
|
| **Ads** | `exodus-ads` | Read your own live Meta ads once the account is connected on the dashboard — `npx @aicopycoders/exodus ads list` (sort by cost per result, spend or CTR), `ads show <adId>` (copy, both windows, media links, comment counts), `npx @aicopycoders/exodus comments list` (already commenter-redacted), and `npx @aicopycoders/exodus winners definition` (what this brand means by a winner). Read-only; no Meta login or MCP needed. |
|
package/assets/docs/PIPELINES.md
CHANGED
|
@@ -16,6 +16,7 @@ In Claude Code you don't click buttons. You say **"exodus"** plus what you want
|
|
|
16
16
|
| exodus-meme | Meme Ad Generator — recommend formats, one batched server-side run |
|
|
17
17
|
| exodus-workflow | Run/build saved multi-node workflows, resolve inbox gate/repair parks, continue sessions, fire triggers, read banks + promote winners |
|
|
18
18
|
| exodus-hooks | Read the Scout library of hook cards — composable filters, one-card detail, pattern matches, CSV export (read-only) |
|
|
19
|
+
| exodus-video | Make a video ad from a Show — start, storyboard gate, pull every piece + manifest, first cut, upload, approve (admin-only) |
|
|
19
20
|
| exodus-browse | View History and Surface the Right Run |
|
|
20
21
|
| exodus-drive | Google Drive, Docs, Sheets via the Dashboard's OAuth |
|
|
21
22
|
| exodus-winners | Mine your own Meta ad account for winners (needs the Meta Ads MCP) and import them into Exodus |
|
|
@@ -222,6 +223,27 @@ Returns: a table, --json data, or an exported CSV/JSON file
|
|
|
222
223
|
|
|
223
224
|
---
|
|
224
225
|
|
|
226
|
+
## exodus-video
|
|
227
|
+
|
|
228
|
+
**What it does:** Makes a video ad from a locked Show, in pieces. The run writes the storyboard, draws a picture per scene, records a voice per scene, renders a clip per scene and composes a music bed, then parks for a cut. The CLI pulls the pieces to a folder with a `manifest.json`, the bundled script makes a plain cut, and the upload attaches it for approval. Admin-only.
|
|
229
|
+
|
|
230
|
+
```operator-guide
|
|
231
|
+
Commands:
|
|
232
|
+
exodus video shows [--json] Shows and whether each is ready
|
|
233
|
+
exodus video start --show <id> --script <file> [--wait] [--json] start an ad run; --wait parks at the storyboard gate
|
|
234
|
+
exodus video storyboard <runId> [--json] the scene cards
|
|
235
|
+
exodus video approve <runId> [--json] approve the storyboard, or the uploaded cut
|
|
236
|
+
exodus video flag <runId> --note "<what is wrong>" [--json] send the storyboard back
|
|
237
|
+
exodus video status <runId> [--json] the park and each scene's clip/voice/picture
|
|
238
|
+
exodus video pull <runId> --out <dir> [--json] every piece + manifest.json
|
|
239
|
+
exodus video upload <runId> --file <cut.mp4> [--duration <s>] [--json] attach the cut (MP4/MOV/WebM, 200 MB)
|
|
240
|
+
Cut:
|
|
241
|
+
node .claude/skills/exodus-video/scripts/first-cut.mjs <dir> [--skip n,m] [--no-music] [--out f]
|
|
242
|
+
Returns: park lines with the exact next command; pull writes files + manifest.json
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
225
247
|
## exodus-browse
|
|
226
248
|
|
|
227
249
|
**What it does:** View past pipeline runs and pull outputs from previous sessions.
|
|
@@ -25,6 +25,7 @@ This skill ROUTES. Read what the user wants, name the destination skill, and han
|
|
|
25
25
|
| Onboard a new brand / build the primer | `exodus-primer` (with winning ads) or `exodus-foundation` (no ads yet) |
|
|
26
26
|
| List/switch/troubleshoot brands | `exodus-brand` |
|
|
27
27
|
| Read the Scout hook library — "what do my 15×+ hooks have in common", "show me my Spanish on-screen hooks", "why did that reel score 22×", "export my hooks to a spreadsheet" | `exodus-hooks` (read-only; promoting a card is a dashboard act) |
|
|
28
|
+
| Make a video ad, or anything about a Show or a video run — "start a video ad from this script", "is my video run done", "pull the clips and cut them", "upload my cut", "what's wrong with scene 3" (`exodus video`) | `exodus-video` (admin-only on the dashboard; it drives start → storyboard → pull → cut → upload) |
|
|
28
29
|
| See past runs / find an output | `exodus-browse` |
|
|
29
30
|
| Open or create Google Docs/Sheets | `exodus-drive` |
|
|
30
31
|
| Read their OWN live Meta ads and their numbers — "what are my cheapest ads", "where is my spend going", "show me that ad", "what are people saying in the comments on my ads" (`exodus ads` / `exodus comments`) | `exodus-ads` (read-only; already synced by the dashboard, no Meta MCP needed) |
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: exodus-video
|
|
3
|
+
description: Make a video ad with Exodus from the terminal. Start an ad from a Show, read and approve its storyboard, pull every finished piece (per-scene clips, voice tracks, keyframes, word timings, the music bed) to a folder, cut them into one video, and upload the cut back for approval, all through the `npx @aicopycoders/exodus video` command family. Use it whenever the user has invoked Exodus and wants anything to do with a video ad, a Show, an ad run's clips or storyboard, "pull the pieces", "stitch it together", "make the cut", "upload my cut", or checking on a video run ("exodus, start a video ad from this script", "exodus, is my video run done", "exodus, pull the clips for run X and cut them", "exodus, what's wrong with scene 3", "exodus video status"). Also use it when the user ran an `npx @aicopycoders/exodus video` command or the `exodus` hub skill routed here. Video is admin-only: "video isn't enabled for this key" means either the dashboard user lacks the admin role or the run id is wrong, so check the id and then say so; do not retry. Never claim generic video-editing asks ("edit this mp4", "add captions to my reel") without Exodus context; in shared folders those belong to the user's other tools. Static image ads are `exodus-image`; copy is `exodus-write`.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Video: make the pieces, cut the ad, hand it back
|
|
7
|
+
|
|
8
|
+
Exodus makes the PIECES of a video ad, not the finished ad. From a locked Show
|
|
9
|
+
(its cast, rooms and voices, set up on the dashboard) and a script, the run
|
|
10
|
+
writes a storyboard, draws one picture per scene, records one voice track per
|
|
11
|
+
scene, renders one video clip per scene, and composes a music bed. Then it
|
|
12
|
+
parks and waits for a cut. You pull the pieces, cut them into one video with
|
|
13
|
+
ffmpeg, and upload the cut. Approving the cut is what makes it the ad.
|
|
14
|
+
|
|
15
|
+
Your job in this skill is to drive that loop and to make a sound first cut.
|
|
16
|
+
Editing craft (captions, pacing, b-roll, sound design) is not here yet; a plain,
|
|
17
|
+
correct assembly is the bar.
|
|
18
|
+
|
|
19
|
+
## Before anything
|
|
20
|
+
|
|
21
|
+
- `npx @aicopycoders/exodus video --help` is the authoritative flag list. The
|
|
22
|
+
`video` verb is admin-only and hidden from the top-level `--help`; that is
|
|
23
|
+
expected, not a broken install.
|
|
24
|
+
- "video isn't enabled for this key" has two causes the CLI cannot tell apart:
|
|
25
|
+
the dashboard user is not an admin on this brand, or the run id does not
|
|
26
|
+
exist. Check the id first; if it is right, the user needs the admin role.
|
|
27
|
+
No flag or retry fixes either.
|
|
28
|
+
- Other failures: `npx @aicopycoders/exodus doctor` first, then follow what it prints.
|
|
29
|
+
- Cutting needs a full `ffmpeg` build with `ffprobe` and the `libx264`
|
|
30
|
+
encoder on the PATH (`brew install ffmpeg` / `apt install ffmpeg`; the
|
|
31
|
+
script checks and says so). Check before you pull, so the user is not left
|
|
32
|
+
with a folder they cannot use.
|
|
33
|
+
- The brand matters: a Show belongs to a brand, so `exodus video shows` lists
|
|
34
|
+
the active brand's Shows. Wrong list means wrong brand; `exodus brand use <slug>`.
|
|
35
|
+
|
|
36
|
+
## The loop
|
|
37
|
+
|
|
38
|
+
Run each line as `npx @aicopycoders/exodus video …`; `exodus` below is shorthand.
|
|
39
|
+
|
|
40
|
+
```operator-guide
|
|
41
|
+
exodus video shows which Shows are ready
|
|
42
|
+
exodus video start --show <id> --script script.txt --wait start, wait for the storyboard gate
|
|
43
|
+
exodus video storyboard <runId> read the scene cards
|
|
44
|
+
exodus video approve <runId> keep going
|
|
45
|
+
exodus video flag <runId> --note "what's wrong" or send it back
|
|
46
|
+
exodus video status <runId> where it is, per scene
|
|
47
|
+
exodus video pull <runId> --out ./ad-<runId> every piece + manifest.json
|
|
48
|
+
node .claude/skills/exodus-video/scripts/first-cut.mjs ./ad-<runId> a plain cut (path from the workspace root)
|
|
49
|
+
exodus video upload <runId> --file ./ad-<runId>/cut.mp4 attach it
|
|
50
|
+
exodus video approve <runId> make it the ad
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Every command takes `--json`. Read `--json` when you need to decide something
|
|
54
|
+
from the output; read the plain form when you are relaying it to the user.
|
|
55
|
+
|
|
56
|
+
**Where a run can stop.** `start --wait` is silent while it polls, then prints
|
|
57
|
+
the stage lines and the stop in one burst. Five stops, each with the exact next
|
|
58
|
+
command printed under it:
|
|
59
|
+
|
|
60
|
+
- storyboard gate: needs `approve` or `flag`.
|
|
61
|
+
- final watch: every piece is made; needs `pull`, a cut, and `upload`.
|
|
62
|
+
- paused: a builder checkpoint the CLI cannot resolve; open the run's page.
|
|
63
|
+
- failed: the run's error is printed and the command exits 1; `status` shows
|
|
64
|
+
how far it got. Tell the user; do not start another run on your own.
|
|
65
|
+
- finished: pull what it made.
|
|
66
|
+
|
|
67
|
+
`status` prints the same stop lines any time, so an agent that lost the
|
|
68
|
+
`--wait` terminal picks up from `status` alone. `--wait` gives up after 60
|
|
69
|
+
minutes with "Still running after 60 minutes" and exit 0; that is not done,
|
|
70
|
+
so check `status` before treating it as finished. Do not poll `status` in a
|
|
71
|
+
tight loop; a full run is several minutes.
|
|
72
|
+
|
|
73
|
+
**What costs money.** `start` creates the run and the storyboard. Approving
|
|
74
|
+
the storyboard is the cost gate: it releases the paid rendering of every
|
|
75
|
+
picture, voice and clip. `shows`, `status`, `storyboard` and `pull` are free
|
|
76
|
+
reads; run them as often as you like. Never start a second run to "retry"
|
|
77
|
+
without the user asking; flag the storyboard or tell them what failed instead.
|
|
78
|
+
|
|
79
|
+
## The script file
|
|
80
|
+
|
|
81
|
+
Plain text. A `CAST:` block that names the speakers exactly as the Show locked
|
|
82
|
+
them, one line per turn, then a `CTA:` block. Keep each turn near 14 words so
|
|
83
|
+
a clip stays near 6 seconds. If a line does get truncated in its clip, the
|
|
84
|
+
manifest says so (`speech-cutoff`).
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
CAST:
|
|
88
|
+
THE EYES — a pair of tired cartoon eyeballs who stare at screens all day
|
|
89
|
+
THE SOFTGEL — a cheerful little capsule who knows how to fix that
|
|
90
|
+
|
|
91
|
+
THE EYES: Ten hours of screens today. Everything looks blurry and dry.
|
|
92
|
+
THE SOFTGEL: That's screen strain. Your eyes are begging for a break.
|
|
93
|
+
|
|
94
|
+
CTA:
|
|
95
|
+
THE SOFTGEL: Tap below and give your eyes ClearBlink.
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Reading the storyboard gate
|
|
99
|
+
|
|
100
|
+
`storyboard <runId>` prints one card per scene: who speaks, the line, the
|
|
101
|
+
planned duration, and whether its picture is drawn. Read it for the user, then
|
|
102
|
+
ask one question: approve, or flag with a note. A flag note is read by the
|
|
103
|
+
model that rewrites the storyboard, so make it concrete ("scene 2 should be a
|
|
104
|
+
close-up of the softgel, not the eyes"). Do not approve on the user's behalf
|
|
105
|
+
unless they told you to run the whole loop unattended.
|
|
106
|
+
|
|
107
|
+
## What `pull` writes, and what the manifest means
|
|
108
|
+
|
|
109
|
+
`pull` writes a flat folder and a `manifest.json` that indexes it. The manifest
|
|
110
|
+
is the data you decide from; the filenames are its values. Scene numbers are
|
|
111
|
+
the run's own (they start at 1; scene 0 in `status` is the reference still).
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
storyboard.json scene text, order, planned durations, cast looks
|
|
115
|
+
reference.<ext> the reference still the pictures were drawn from
|
|
116
|
+
scene-NN.keyframe.<ext> the picture for scene NN
|
|
117
|
+
scene-NN.voice.<ext> the voice track for scene NN, when one was delivered
|
|
118
|
+
(a Show whose voices live inside the clips delivers none)
|
|
119
|
+
scene-NN.<ext> the clip for scene NN, usually .mp4, voice included
|
|
120
|
+
scene-NN.words.json [{w, s, e}] word timings inside that clip, for captions
|
|
121
|
+
music.<ext> the music bed, composed to the clips' total length
|
|
122
|
+
manifest.json the index below
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`manifest.json`:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
runId, pulledAt, dashboardUrl the run and its page
|
|
129
|
+
storyboard, reference, music filenames, or null when not delivered
|
|
130
|
+
scenes[] one per scene, in order
|
|
131
|
+
sceneIndex, durationSec the run's number and the clip's real length
|
|
132
|
+
clip, voice, keyframe, words filenames, or null
|
|
133
|
+
clipStatus done | failed | running | pending | missing
|
|
134
|
+
error why the clip failed, when it did
|
|
135
|
+
flagged, findings[] QC verdict: {check, code, severity: fail|warn, detail}
|
|
136
|
+
qc {verdict, attempts} from the renderer
|
|
137
|
+
failed[] files that did not download: {file, url, error}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
How to read it before cutting:
|
|
141
|
+
|
|
142
|
+
- `clipStatus: "done"` and a `clip` filename: the scene is cuttable.
|
|
143
|
+
- `flagged: true` is a warning, not a block. The clip was delivered anyway; the
|
|
144
|
+
findings say what the QC model saw (`wrong-character`, `eyeline-off`,
|
|
145
|
+
`set-drift`, `speech-cutoff`, `framing-off`). Tell the user which scenes are
|
|
146
|
+
flagged and why, and let them decide whether to keep, trim, or drop each one.
|
|
147
|
+
A `speech-cutoff` on the CTA scene is the one to worry about; the ad's last
|
|
148
|
+
words are missing.
|
|
149
|
+
- `clipStatus: "failed"` or `"missing"` with a `keyframe`: `durationSec` is
|
|
150
|
+
null (it comes from the clip), but the scene can still hold its place as a
|
|
151
|
+
still picture for the length of its voice track, or the storyboard's planned
|
|
152
|
+
duration when there is no voice. The first-cut script does this by itself.
|
|
153
|
+
- `clipStatus: "running"` or `"pending"`: pull again later. `status` says when
|
|
154
|
+
the run parks at the final watch, which means nothing is still rendering.
|
|
155
|
+
- `failed[]` non-empty: run the same `pull` again. It fetches every file again
|
|
156
|
+
and overwrites, so nothing is lost; the new manifest says what still failed.
|
|
157
|
+
|
|
158
|
+
## Making the first cut
|
|
159
|
+
|
|
160
|
+
Use the bundled script. It reads the manifest, puts every A-roll scene in order
|
|
161
|
+
as the spine, lays each cutaway over the spine at the moment its line is spoken,
|
|
162
|
+
normalizes everything to 1080x1920 at 24 fps, fills a silent clip with the
|
|
163
|
+
scene's voice track, lays the music bed underneath at a low level, and writes one
|
|
164
|
+
MP4 with faststart for upload. The path is from the workspace root; from a brand
|
|
165
|
+
subfolder, prefix `../`:
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
node .claude/skills/exodus-video/scripts/first-cut.mjs ./ad-<runId>
|
|
169
|
+
node .claude/skills/exodus-video/scripts/first-cut.mjs ./ad-<runId> --skip 2,5 --no-music --out ./v2.mp4
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
It prints what went in, what was left out and why, and the upload command.
|
|
173
|
+
Reach for raw ffmpeg only when the user wants something the script does not do
|
|
174
|
+
(a trim, a reorder, a different aspect). When you do, keep the script's output
|
|
175
|
+
contract: H.264 + AAC in an MP4, an even-sized frame, `-movflags +faststart`.
|
|
176
|
+
|
|
177
|
+
### The word times that come out with the cut
|
|
178
|
+
|
|
179
|
+
Nothing burns captions into the video. Captions belong in post, in whatever tool
|
|
180
|
+
the editor uses, so the script hands those tools the timings instead. Beside the
|
|
181
|
+
MP4 it writes two files named from the same basename. `cut.words.json` is every
|
|
182
|
+
spoken word of the finished ad with its start and end in seconds. `cut.srt` is
|
|
183
|
+
the same words grouped into short subtitle lines. `--out v2.mp4` names them
|
|
184
|
+
`v2.words.json` and `v2.srt`.
|
|
185
|
+
|
|
186
|
+
The times are on the finished ad's timeline, so a word's time is where you hear
|
|
187
|
+
it in the MP4. Cutaways contribute nothing, because their audio never plays. A
|
|
188
|
+
scene that came with no word times leaves a gap, and the report names it. When no
|
|
189
|
+
scene delivered word times the script writes neither file and says so. Tell the
|
|
190
|
+
user the two files exist and that they are what the editor imports for captions.
|
|
191
|
+
|
|
192
|
+
### Where a cutaway lands
|
|
193
|
+
|
|
194
|
+
The storyboard marks some scenes `kind: "cutaway"` and gives each one a
|
|
195
|
+
`cueLineId`, the script line the cutaway belongs to. A cutaway is a picture-only
|
|
196
|
+
takeover. It replaces the picture for its own length while the spoken track
|
|
197
|
+
underneath keeps running, so it never takes a place in the running order and
|
|
198
|
+
never adds audio. That is why the cut is as long as the A-roll scenes alone. A
|
|
199
|
+
cutaway is cut short where the next cutaway starts or where the ad ends, and
|
|
200
|
+
the report says so.
|
|
201
|
+
|
|
202
|
+
The script places each cutaway at the real time its cued line is spoken. It
|
|
203
|
+
finds the A-roll scene whose `lineIds` hold the cue line, counts the words of
|
|
204
|
+
the lines spoken before it in that scene, and reads that word's start time out
|
|
205
|
+
of `scene-NN.words.json`. When the scene has no word times, it falls back to a
|
|
206
|
+
proportion, the share of the scene's words that come before the cue line scaled
|
|
207
|
+
to the scene's real length. The proportion is an estimate and can land a beat
|
|
208
|
+
early or late, so the report names which of the two methods placed each cutaway.
|
|
209
|
+
|
|
210
|
+
A cutaway whose cue line is spoken by no scene in the cut cannot be placed, so
|
|
211
|
+
the script leaves it out and says so. Skipping the A-roll scene that speaks the
|
|
212
|
+
cue line does that, and so does a storyboard that never claims the line.
|
|
213
|
+
|
|
214
|
+
Before uploading, look at what you made: `ffprobe -v error -show_entries
|
|
215
|
+
format=duration -of default=nw=1:nk=1 cut.mp4` should be close to the sum of
|
|
216
|
+
the scene durations you kept. A cut that is a few seconds long when five clips
|
|
217
|
+
went in means a filter dropped inputs; do not upload it.
|
|
218
|
+
|
|
219
|
+
## Uploading and approving
|
|
220
|
+
|
|
221
|
+
`upload <runId> --file cut.mp4` accepts MP4, MOV or WebM up to 200 MB. It reads
|
|
222
|
+
the length off the file (MP4 headers, or ffprobe for the rest); when it cannot,
|
|
223
|
+
it says so and you pass `--duration <sec>`.
|
|
224
|
+
It prints the run's page, where the user can watch the cut, and the approve
|
|
225
|
+
command. Approve only when the user has seen the cut or told you to run
|
|
226
|
+
unattended; `approve` marks the cut as the ad and moves the run to delivery.
|
|
227
|
+
|
|
228
|
+
## Reporting to the user
|
|
229
|
+
|
|
230
|
+
Lead with where the run is and what it needs from them. Then, when you pulled
|
|
231
|
+
or cut: how many scenes, which are flagged and why in one line each, what you
|
|
232
|
+
left out, the cut's length, and the exact command or link for the next step.
|
|
233
|
+
Never paste the manifest; summarize it.
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// A plain first cut from a folder written by `exodus video pull`: the A-roll
|
|
3
|
+
// scenes in the manifest's order make the spine, each cutaway lays over the
|
|
4
|
+
// spine at the moment its cued line is spoken, the music bed goes underneath,
|
|
5
|
+
// and one MP4 comes out ready to upload.
|
|
6
|
+
//
|
|
7
|
+
// node first-cut.mjs <pulled-dir> [--out cut.mp4] [--skip 2,5] [--no-music]
|
|
8
|
+
//
|
|
9
|
+
// A scene with a clip contributes the clip. A clip with no audio stream gets
|
|
10
|
+
// the scene's voice track, or silence. A scene with no clip but a keyframe
|
|
11
|
+
// becomes a still for the length of its voice track, else the storyboard's
|
|
12
|
+
// planned duration, with the voice if one was delivered. --skip drops scenes.
|
|
13
|
+
//
|
|
14
|
+
// After the render it writes the whole ad's word times beside the MP4, as
|
|
15
|
+
// <out>.words.json and <out>.srt, for captioning in post.
|
|
16
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
17
|
+
import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
import { pathToFileURL } from "node:url";
|
|
20
|
+
|
|
21
|
+
const USAGE = "usage: first-cut.mjs <pulled-dir> [--out cut.mp4] [--skip 2,5] [--no-music]";
|
|
22
|
+
const WIDTH = 1080;
|
|
23
|
+
const HEIGHT = 1920;
|
|
24
|
+
const FPS = 24;
|
|
25
|
+
const norm = (label) =>
|
|
26
|
+
`[${label}]scale=${WIDTH}:${HEIGHT}:force_original_aspect_ratio=decrease,` +
|
|
27
|
+
`pad=${WIDTH}:${HEIGHT}:(ow-iw)/2:(oh-ih)/2,setsar=1,fps=${FPS},format=yuv420p`;
|
|
28
|
+
const stereo = "aresample=48000,aformat=channel_layouts=stereo";
|
|
29
|
+
|
|
30
|
+
/** The word rule the planner sized every line with (scout models.ts wordCount). */
|
|
31
|
+
export function wordCount(text) {
|
|
32
|
+
const trimmed = (text ?? "").trim();
|
|
33
|
+
return trimmed ? trimmed.split(/\s+/).length : 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function lineWordCounts(storyboard) {
|
|
37
|
+
const counts = new Map();
|
|
38
|
+
for (const line of storyboard?.script ?? []) {
|
|
39
|
+
if (typeof line?.lineId === "string") counts.set(line.lineId, wordCount(line.text));
|
|
40
|
+
}
|
|
41
|
+
return counts;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const CUTAWAY_KINDS = new Set(["cutaway", "insert"]);
|
|
45
|
+
|
|
46
|
+
export function scenePlans(storyboard) {
|
|
47
|
+
const plans = new Map();
|
|
48
|
+
for (const scene of storyboard?.scenes ?? []) {
|
|
49
|
+
if (typeof scene?.sceneIndex !== "number") continue;
|
|
50
|
+
plans.set(scene.sceneIndex, {
|
|
51
|
+
cutaway: CUTAWAY_KINDS.has(scene.kind),
|
|
52
|
+
lineIds: Array.isArray(scene.lineIds) ? scene.lineIds : [],
|
|
53
|
+
cueLineId: typeof scene.cueLineId === "string" ? scene.cueLineId : null,
|
|
54
|
+
durationSec: typeof scene.durationSec === "number" ? scene.durationSec : null,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return plans;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function cueOffsetOnSpine(spine, counts, cueLineId) {
|
|
61
|
+
for (const seg of spine) {
|
|
62
|
+
const idx = seg.lineIds.indexOf(cueLineId);
|
|
63
|
+
if (idx === -1) continue;
|
|
64
|
+
let precedingWords = 0;
|
|
65
|
+
for (let i = 0; i < idx; i++) precedingWords += counts.get(seg.lineIds[i]) ?? 0;
|
|
66
|
+
let totalWords = 0;
|
|
67
|
+
for (const id of seg.lineIds) totalWords += counts.get(id) ?? 0;
|
|
68
|
+
|
|
69
|
+
let within = 0;
|
|
70
|
+
let method = "proportion";
|
|
71
|
+
if (seg.words && seg.words.length > 0) {
|
|
72
|
+
within = Math.max(0, seg.words[Math.min(precedingWords, seg.words.length - 1)]?.s ?? 0);
|
|
73
|
+
method = "words";
|
|
74
|
+
} else if (totalWords > 0) {
|
|
75
|
+
within = (precedingWords / totalWords) * seg.seconds;
|
|
76
|
+
}
|
|
77
|
+
within = Math.min(within, seg.seconds);
|
|
78
|
+
return { startSec: seg.startSec + within, method, spineSceneIndex: seg.sceneIndex };
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function buildTimeline({ manifest, storyboard, skip, probe, exists, readWords }) {
|
|
84
|
+
const plans = scenePlans(storyboard);
|
|
85
|
+
const counts = lineWordCounts(storyboard);
|
|
86
|
+
const spine = [];
|
|
87
|
+
const cutaways = [];
|
|
88
|
+
const waiting = [];
|
|
89
|
+
const dropped = [];
|
|
90
|
+
let startSec = 0;
|
|
91
|
+
|
|
92
|
+
for (const scene of manifest?.scenes ?? []) {
|
|
93
|
+
const n = scene.sceneIndex;
|
|
94
|
+
const plan = plans.get(n) ?? { cutaway: false, lineIds: [], cueLineId: null, durationSec: null };
|
|
95
|
+
if (skip.has(n)) {
|
|
96
|
+
dropped.push({ n, reason: `scene ${n}: skipped by --skip` });
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const nothing = `nothing to cut with (clip ${scene.clipStatus}${scene.error ? `: ${scene.error}` : ""})`;
|
|
100
|
+
|
|
101
|
+
if (plan.cutaway) {
|
|
102
|
+
if (exists(scene.clip)) {
|
|
103
|
+
waiting.push({
|
|
104
|
+
sceneIndex: n, source: "clip", file: scene.clip,
|
|
105
|
+
seconds: probe(scene.clip).seconds, cueLineId: plan.cueLineId,
|
|
106
|
+
});
|
|
107
|
+
} else if (exists(scene.keyframe)) {
|
|
108
|
+
waiting.push({
|
|
109
|
+
sceneIndex: n, source: "still", file: scene.keyframe,
|
|
110
|
+
seconds: plan.durationSec ?? 4, cueLineId: plan.cueLineId,
|
|
111
|
+
});
|
|
112
|
+
} else {
|
|
113
|
+
dropped.push({ n, reason: `cutaway ${n}: ${nothing}` });
|
|
114
|
+
}
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (exists(scene.clip)) {
|
|
119
|
+
const clip = probe(scene.clip);
|
|
120
|
+
const voice = clip.hasAudio || !exists(scene.voice) ? null : scene.voice;
|
|
121
|
+
const flag = scene.flagged ? " (flagged)" : "";
|
|
122
|
+
const silent = clip.hasAudio ? "" : voice ? `, silent clip + ${voice}` : ", silent clip";
|
|
123
|
+
spine.push({
|
|
124
|
+
sceneIndex: n, source: "clip", file: scene.clip, seconds: clip.seconds,
|
|
125
|
+
hasAudio: clip.hasAudio, voice, startSec, lineIds: plan.lineIds,
|
|
126
|
+
words: readWords(scene.words), note: `${flag}${silent}`,
|
|
127
|
+
});
|
|
128
|
+
startSec += clip.seconds;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (exists(scene.keyframe)) {
|
|
132
|
+
const voice = exists(scene.voice) ? scene.voice : null;
|
|
133
|
+
const seconds = voice ? probe(voice).seconds : (plan.durationSec ?? 4);
|
|
134
|
+
spine.push({
|
|
135
|
+
sceneIndex: n, source: "still", file: scene.keyframe, seconds,
|
|
136
|
+
hasAudio: false, voice, startSec, lineIds: plan.lineIds,
|
|
137
|
+
words: null,
|
|
138
|
+
note: `${voice ? ` + ${voice}` : ", silent"} (${seconds.toFixed(1)}s, clip ${scene.clipStatus})`,
|
|
139
|
+
});
|
|
140
|
+
startSec += seconds;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
dropped.push({ n, reason: `scene ${n}: ${nothing}` });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
for (const c of waiting) {
|
|
147
|
+
const cue = c.cueLineId ? cueOffsetOnSpine(spine, counts, c.cueLineId) : null;
|
|
148
|
+
if (!cue) {
|
|
149
|
+
const why = c.cueLineId
|
|
150
|
+
? `${c.cueLineId} is spoken by no scene in the cut`
|
|
151
|
+
: "the storyboard names no cue line";
|
|
152
|
+
dropped.push({ n: c.sceneIndex, reason: `cutaway ${c.sceneIndex}: ${why}` });
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
cutaways.push({ ...c, startSec: cue.startSec, method: cue.method, spineSceneIndex: cue.spineSceneIndex });
|
|
156
|
+
}
|
|
157
|
+
cutaways.sort((a, b) => a.startSec - b.startSec);
|
|
158
|
+
for (let i = 0; i < cutaways.length; i++) {
|
|
159
|
+
const c = cutaways[i];
|
|
160
|
+
const next = cutaways[i + 1];
|
|
161
|
+
const end = Math.min(startSec, next ? next.startSec : Infinity);
|
|
162
|
+
if (c.startSec + c.seconds > end) {
|
|
163
|
+
c.seconds = Math.max(0, end - c.startSec);
|
|
164
|
+
c.cutShortBy = next && end === next.startSec ? `cutaway ${next.sceneIndex} starts` : "the ad ends";
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
spine,
|
|
170
|
+
cutaways,
|
|
171
|
+
left: dropped.sort((a, b) => a.n - b.n).map((d) => d.reason),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function sec(n) {
|
|
176
|
+
return (Number.isFinite(n) ? Math.max(0, n) : 0).toFixed(3);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function buildFfmpegArgs(timeline, { resolve, music, out }) {
|
|
180
|
+
const inputs = [];
|
|
181
|
+
let count = 0;
|
|
182
|
+
const addInput = (...args) => {
|
|
183
|
+
inputs.push(...args);
|
|
184
|
+
return count++;
|
|
185
|
+
};
|
|
186
|
+
const filters = [];
|
|
187
|
+
const pairs = [];
|
|
188
|
+
|
|
189
|
+
for (const seg of timeline.spine) {
|
|
190
|
+
const i =
|
|
191
|
+
seg.source === "clip"
|
|
192
|
+
? addInput("-i", resolve(seg.file))
|
|
193
|
+
: addInput("-loop", "1", "-t", String(seg.seconds), "-i", resolve(seg.file));
|
|
194
|
+
filters.push(`${norm(`${i}:v`)}[v${i}]`);
|
|
195
|
+
if (seg.hasAudio) {
|
|
196
|
+
filters.push(`[${i}:a]${stereo}[a${i}]`);
|
|
197
|
+
} else if (seg.voice) {
|
|
198
|
+
const v = addInput("-i", resolve(seg.voice));
|
|
199
|
+
filters.push(`[${v}:a]${stereo},apad,atrim=0:${seg.seconds}[a${i}]`);
|
|
200
|
+
} else {
|
|
201
|
+
filters.push(`anullsrc=r=48000:cl=stereo,atrim=0:${seg.seconds}[a${i}]`);
|
|
202
|
+
}
|
|
203
|
+
pairs.push(`[v${i}][a${i}]`);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// A clip whose audio ends before its video would otherwise end the whole cut
|
|
207
|
+
// there under -shortest; padding lets the video decide the length.
|
|
208
|
+
filters.push(`${pairs.join("")}concat=n=${pairs.length}:v=1:a=1[vcat][voicecat]`);
|
|
209
|
+
filters.push(`[voicecat]apad[voice]`);
|
|
210
|
+
|
|
211
|
+
let videoLabel = "vcat";
|
|
212
|
+
timeline.cutaways.forEach((c, j) => {
|
|
213
|
+
const i =
|
|
214
|
+
c.source === "clip"
|
|
215
|
+
? addInput("-i", resolve(c.file))
|
|
216
|
+
: addInput("-loop", "1", "-t", String(c.seconds), "-i", resolve(c.file));
|
|
217
|
+
const end = c.startSec + c.seconds;
|
|
218
|
+
filters.push(
|
|
219
|
+
`${norm(`${i}:v`)},trim=0:${sec(c.seconds)},setpts=PTS-STARTPTS+${sec(c.startSec)}/TB[cv${j}]`,
|
|
220
|
+
);
|
|
221
|
+
// eof_action=pass keeps the spine showing once the cutaway's frames end.
|
|
222
|
+
filters.push(
|
|
223
|
+
`[${videoLabel}][cv${j}]overlay=enable=between(t\\,${sec(c.startSec)}\\,${sec(end)}):eof_action=pass[ov${j}]`,
|
|
224
|
+
);
|
|
225
|
+
videoLabel = `ov${j}`;
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
let audioLabel = "voice";
|
|
229
|
+
if (music) {
|
|
230
|
+
const m = addInput("-stream_loop", "-1", "-i", music);
|
|
231
|
+
filters.push(`[${m}:a]${stereo},volume=0.18[bed]`);
|
|
232
|
+
filters.push(`[voice][bed]amix=inputs=2:duration=first:dropout_transition=0:normalize=0[mix]`);
|
|
233
|
+
audioLabel = "mix";
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return [
|
|
237
|
+
"-y", "-hide_banner", "-loglevel", "error",
|
|
238
|
+
...inputs,
|
|
239
|
+
"-filter_complex", filters.join(";"),
|
|
240
|
+
"-map", `[${videoLabel}]`, "-map", `[${audioLabel}]`,
|
|
241
|
+
"-c:v", "libx264", "-preset", "medium", "-crf", "20", "-r", String(FPS),
|
|
242
|
+
"-c:a", "aac", "-b:a", "192k",
|
|
243
|
+
"-movflags", "+faststart", "-shortest",
|
|
244
|
+
out,
|
|
245
|
+
];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function wordRows(timeline) {
|
|
249
|
+
const ms = (n) => Math.round(n * 1000) / 1000;
|
|
250
|
+
const rows = [];
|
|
251
|
+
for (const seg of timeline.spine) {
|
|
252
|
+
for (const w of seg.words ?? []) {
|
|
253
|
+
const text = (w.w ?? "").trim();
|
|
254
|
+
const start = seg.startSec + w.s;
|
|
255
|
+
const end = seg.startSec + w.e;
|
|
256
|
+
if (text && end > start) {
|
|
257
|
+
rows.push({ text, start: ms(start), end: ms(end), scene: seg.sceneIndex });
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return rows;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const SRT_MAX_WORDS = 5;
|
|
265
|
+
const SRT_GAP_SEC = 1.0;
|
|
266
|
+
|
|
267
|
+
export function srtCues(rows) {
|
|
268
|
+
const cues = [];
|
|
269
|
+
let cue = [];
|
|
270
|
+
for (let i = 0; i < rows.length; i++) {
|
|
271
|
+
cue.push(rows[i]);
|
|
272
|
+
const next = rows[i + 1];
|
|
273
|
+
const ends =
|
|
274
|
+
!next ||
|
|
275
|
+
/[.!?,;:]$/.test(rows[i].text) ||
|
|
276
|
+
cue.length >= SRT_MAX_WORDS ||
|
|
277
|
+
next.scene !== rows[i].scene ||
|
|
278
|
+
next.start - rows[i].end > SRT_GAP_SEC;
|
|
279
|
+
if (ends) {
|
|
280
|
+
cues.push(cue);
|
|
281
|
+
cue = [];
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return cues;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export function srtTime(seconds) {
|
|
288
|
+
const ms = Math.max(0, Math.round(seconds * 1000));
|
|
289
|
+
const pad = (n, width) => String(n).padStart(width, "0");
|
|
290
|
+
return (
|
|
291
|
+
`${pad(Math.floor(ms / 3600000), 2)}:${pad(Math.floor(ms / 60000) % 60, 2)}:` +
|
|
292
|
+
`${pad(Math.floor(ms / 1000) % 60, 2)},${pad(ms % 1000, 3)}`
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function toSrt(rows) {
|
|
297
|
+
return srtCues(rows)
|
|
298
|
+
.map((cue, i) => {
|
|
299
|
+
const text = cue.map((r) => r.text).join(" ");
|
|
300
|
+
return `${i + 1}\n${srtTime(cue[0].start)} --> ${srtTime(cue[cue.length - 1].end)}\n${text}\n`;
|
|
301
|
+
})
|
|
302
|
+
.join("\n");
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export function sidecarPaths(outPath) {
|
|
306
|
+
const dir = path.dirname(outPath);
|
|
307
|
+
const base = path.basename(outPath, path.extname(outPath));
|
|
308
|
+
return { words: path.join(dir, `${base}.words.json`), srt: path.join(dir, `${base}.srt`) };
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export function inTheCut(timeline) {
|
|
312
|
+
const rows = [];
|
|
313
|
+
for (const seg of timeline.spine) {
|
|
314
|
+
const label = seg.source === "clip" ? seg.file : `still ${seg.file}`;
|
|
315
|
+
rows.push({ n: seg.sceneIndex, line: `scene ${seg.sceneIndex}: ${label}${seg.note}` });
|
|
316
|
+
}
|
|
317
|
+
for (const c of timeline.cutaways) {
|
|
318
|
+
const label = c.source === "clip" ? c.file : `still ${c.file}`;
|
|
319
|
+
const how =
|
|
320
|
+
c.method === "words"
|
|
321
|
+
? "word times"
|
|
322
|
+
: `proportion: scene ${c.spineSceneIndex} has no word times`;
|
|
323
|
+
const cut = c.cutShortBy ? `, cut short where ${c.cutShortBy}` : "";
|
|
324
|
+
rows.push({
|
|
325
|
+
n: c.sceneIndex,
|
|
326
|
+
line:
|
|
327
|
+
`cutaway ${c.sceneIndex}: ${label} at ${c.startSec.toFixed(2)}s for ${c.seconds.toFixed(1)}s, ` +
|
|
328
|
+
`cued to ${c.cueLineId} in scene ${c.spineSceneIndex} (${how})${cut}`,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
return rows.sort((a, b) => a.n - b.n).map((r) => r.line);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export function noWordTimes(timeline) {
|
|
335
|
+
const rows = timeline.spine
|
|
336
|
+
.filter((seg) => !seg.words || seg.words.length === 0)
|
|
337
|
+
.map((seg) => `scene ${seg.sceneIndex} (no words.json)`);
|
|
338
|
+
for (const c of timeline.cutaways) rows.push(`scene ${c.sceneIndex} (cutaway)`);
|
|
339
|
+
return rows;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function fail(code, message) {
|
|
343
|
+
console.error(message);
|
|
344
|
+
process.exit(code);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function parseArgs(argv) {
|
|
348
|
+
const opts = { dir: undefined, out: undefined, skip: new Set(), music: true };
|
|
349
|
+
for (let i = 0; i < argv.length; i++) {
|
|
350
|
+
const a = argv[i];
|
|
351
|
+
if (a === "--out") opts.out = argv[++i];
|
|
352
|
+
else if (a === "--skip") opts.skip = new Set((argv[++i] ?? "").split(",").filter(Boolean).map(Number));
|
|
353
|
+
else if (a === "--no-music") opts.music = false;
|
|
354
|
+
else if (a.startsWith("--")) fail(2, `unknown flag ${a}\n${USAGE}`);
|
|
355
|
+
else if (opts.dir === undefined) opts.dir = a;
|
|
356
|
+
else fail(2, `unexpected argument ${a}\n${USAGE}`);
|
|
357
|
+
}
|
|
358
|
+
if (!opts.dir) fail(2, USAGE);
|
|
359
|
+
return opts;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function main() {
|
|
363
|
+
const opts = parseArgs(process.argv.slice(2));
|
|
364
|
+
|
|
365
|
+
for (const bin of ["ffmpeg", "ffprobe"]) {
|
|
366
|
+
if (spawnSync(bin, ["-version"]).status !== 0) {
|
|
367
|
+
fail(2, `${bin} is not installed. Install ffmpeg (brew install ffmpeg / apt install ffmpeg).`);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const encoders = spawnSync("ffmpeg", ["-hide_banner", "-encoders"]).stdout?.toString() ?? "";
|
|
371
|
+
if (!/\blibx264\b/.test(encoders)) {
|
|
372
|
+
fail(2, "This ffmpeg has no libx264 encoder (H.264). Install a full ffmpeg build: brew install ffmpeg / apt install ffmpeg.");
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const dir = opts.dir;
|
|
376
|
+
const manifestPath = path.join(dir, "manifest.json");
|
|
377
|
+
if (!existsSync(manifestPath)) {
|
|
378
|
+
fail(2, `${manifestPath} not found. Run: exodus video pull <runId> --out ${dir}`);
|
|
379
|
+
}
|
|
380
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
381
|
+
const out = path.resolve(opts.out ?? path.join(dir, "cut.mp4"));
|
|
382
|
+
const here = (file) => path.join(dir, file);
|
|
383
|
+
const exists = (file) => Boolean(file) && existsSync(here(file));
|
|
384
|
+
|
|
385
|
+
const readJson = (file) => {
|
|
386
|
+
if (!exists(file)) return null;
|
|
387
|
+
try {
|
|
388
|
+
return JSON.parse(readFileSync(here(file), "utf8"));
|
|
389
|
+
} catch {
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
const probe = (file) => {
|
|
394
|
+
const raw = execFileSync("ffprobe", [
|
|
395
|
+
"-v", "error", "-show_entries", "stream=codec_type:format=duration", "-of", "json", here(file),
|
|
396
|
+
]).toString();
|
|
397
|
+
const info = JSON.parse(raw);
|
|
398
|
+
return {
|
|
399
|
+
seconds: Number(info.format?.duration ?? 0),
|
|
400
|
+
hasAudio: (info.streams ?? []).some((s) => s.codec_type === "audio"),
|
|
401
|
+
};
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
const storyboard = readJson(manifest.storyboard);
|
|
405
|
+
if (!storyboard) {
|
|
406
|
+
console.error(`Warning: ${manifest.storyboard ?? "storyboard.json"} is missing or unreadable, so every scene is cut as A-roll and no cutaway is placed.`);
|
|
407
|
+
}
|
|
408
|
+
const timeline = buildTimeline({
|
|
409
|
+
manifest,
|
|
410
|
+
storyboard,
|
|
411
|
+
skip: opts.skip,
|
|
412
|
+
probe,
|
|
413
|
+
exists,
|
|
414
|
+
readWords: (file) => {
|
|
415
|
+
const rows = readJson(file);
|
|
416
|
+
return Array.isArray(rows) && rows.length > 0 ? rows : null;
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
if (timeline.spine.length === 0) {
|
|
420
|
+
fail(1, `No scene has a clip or a keyframe. Check: exodus video status ${manifest.runId}`);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const music = opts.music && exists(manifest.music) ? manifest.music : null;
|
|
424
|
+
const ffmpegArgs = buildFfmpegArgs(timeline, {
|
|
425
|
+
resolve: here,
|
|
426
|
+
music: music ? here(music) : null,
|
|
427
|
+
out,
|
|
428
|
+
});
|
|
429
|
+
const res = spawnSync("ffmpeg", ffmpegArgs, { stdio: "inherit" });
|
|
430
|
+
if (res.status !== 0) {
|
|
431
|
+
const quoted = ffmpegArgs.map((a) => (/[\s\[\];]/.test(a) ? `'${a}'` : a)).join(" ");
|
|
432
|
+
fail(1, `ffmpeg failed. The command it ran:\n ffmpeg ${quoted}`);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const rows = wordRows(timeline);
|
|
436
|
+
const sidecars = sidecarPaths(out);
|
|
437
|
+
if (rows.length > 0) {
|
|
438
|
+
writeFileSync(sidecars.words, `${JSON.stringify(rows, null, 2)}\n`);
|
|
439
|
+
writeFileSync(sidecars.srt, toSrt(rows));
|
|
440
|
+
} else {
|
|
441
|
+
rmSync(sidecars.words, { force: true });
|
|
442
|
+
rmSync(sidecars.srt, { force: true });
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const duration = execFileSync("ffprobe", [
|
|
446
|
+
"-v", "error", "-show_entries", "format=duration", "-of", "default=nw=1:nk=1", out,
|
|
447
|
+
]).toString().trim();
|
|
448
|
+
console.log(`Wrote ${out} (${Number(duration).toFixed(1)}s, ${WIDTH}x${HEIGHT})`);
|
|
449
|
+
console.log("In the cut:");
|
|
450
|
+
for (const line of inTheCut(timeline)) console.log(" " + line);
|
|
451
|
+
if (timeline.left.length > 0) {
|
|
452
|
+
console.log("Left out:");
|
|
453
|
+
for (const line of timeline.left) console.log(" " + line);
|
|
454
|
+
}
|
|
455
|
+
if (rows.length > 0) {
|
|
456
|
+
const scenes = [...new Set(rows.map((r) => r.scene))].join(", ");
|
|
457
|
+
console.log(
|
|
458
|
+
`Words: ${rows.length} words from scenes ${scenes} -> ${path.basename(sidecars.words)}, ${path.basename(sidecars.srt)}`,
|
|
459
|
+
);
|
|
460
|
+
} else {
|
|
461
|
+
console.log("Words: none delivered, no caption files written");
|
|
462
|
+
}
|
|
463
|
+
const silent = noWordTimes(timeline);
|
|
464
|
+
if (silent.length > 0) console.log(`No word times: ${silent.join(", ")}`);
|
|
465
|
+
console.log(`Music bed: ${music ?? "none"}`);
|
|
466
|
+
console.log(`Upload it: exodus video upload ${manifest.runId} --file ${out}`);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) main();
|