@makemidas/cli 0.4.0 → 0.6.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/README.md +22 -1
- package/dist/api.js +50 -5
- package/dist/args.js +2 -2
- package/dist/cli.js +20 -3
- package/dist/commands.js +48 -0
- package/dist/config.js +1 -1
- package/dist/film-edit.js +280 -0
- package/dist/films.js +1 -1
- package/fonts/OFL.txt +93 -0
- package/fonts/inter-latin-900-normal.woff2 +0 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -53,11 +53,12 @@ makemidas film new "a 15-second social video for our mugs" --style social --max-
|
|
|
53
53
|
| `list [--limit n] [--before t]` | Recent generations |
|
|
54
54
|
| `delete <id> [--yes]` | Delete a finished or failed generation and its files (no refund) |
|
|
55
55
|
| `credits` | Balance, plan, expiring credits |
|
|
56
|
+
| `credits activity [--generation <id>] [--limit n] [--before t]` | Grants, charges and refunds, newest first; with `--generation`, what one generation charged and refunded |
|
|
56
57
|
| `credits buy` (or `credits link`) | Links to buy a plan or credit pack, with prices; opens nothing |
|
|
57
58
|
| `models [image\|video\|audio\|transcription\|edit]` | Model ids, options and credit prices |
|
|
58
59
|
| `models <id>` | One model: options, defaults, voices, prices and an example request |
|
|
59
60
|
| `estimate <command> "<prompt>"\|<file>` | Price a request without charging; `<command>` is `image`, `video`, `music`, `sfx`, `speech`, `transcribe`, `remove-bg`, `upscale`, `upscale-video` or `avatar`, with that command's options |
|
|
60
|
-
| `feedback "<message>" [--kind bug\|feature\|praise\|other] [--generation <id>]` | Send feedback to the MakeMidas team |
|
|
61
|
+
| `feedback "<message>" [--kind bug\|quality\|feature\|praise\|other] [--generation <id>]` | Send feedback to the MakeMidas team (`quality`: a result clearly short of the request) |
|
|
61
62
|
|
|
62
63
|
Common options: `--model`, `--aspect`, `--resolution`, `--count`, `--ref`
|
|
63
64
|
(file or URL, repeatable), `--style`, `--enhance`, `--duration`, `--audio`,
|
|
@@ -106,6 +107,13 @@ stdin is not a terminal), 3 not signed in, 4 not enough credits, a plan
|
|
|
106
107
|
limit or busy (also over `--max-credits`), 5 generation failed (credits
|
|
107
108
|
refunded), 6 network or server error, 7 still rendering.
|
|
108
109
|
|
|
110
|
+
Every generating request carries an `Idempotency-Key`. When its answer is
|
|
111
|
+
lost (a dropped connection, a server error), the CLI asks again with the
|
|
112
|
+
same key after 2, 5 and 10 seconds; MakeMidas answers the generation the
|
|
113
|
+
first attempt started, so nothing is made or charged twice. Exit 6 after
|
|
114
|
+
that means it still had no answer: look for the generation with
|
|
115
|
+
`makemidas list` before running the command again.
|
|
116
|
+
|
|
109
117
|
## Talking avatars
|
|
110
118
|
|
|
111
119
|
`avatar` turns one portrait photo and a voice track into a lip-synced video
|
|
@@ -213,6 +221,10 @@ makemidas film approve <id> film --quoted-credits <n> --wait -o .
|
|
|
213
221
|
# Redo one piece, or take the pieces and cut it yourself
|
|
214
222
|
makemidas film redo <id> 2 clip --max-credits 40
|
|
215
223
|
makemidas film download <id> --pieces -o ./cut # clips, audio, timeline.json
|
|
224
|
+
|
|
225
|
+
# Re-cut a finished film on this computer: word-by-word captions, slow push-ins
|
|
226
|
+
makemidas film edit <id> -o . # a HyperFrames project
|
|
227
|
+
cd film-<id8>-edit && npm run render # renders/film.mp4, free
|
|
216
228
|
```
|
|
217
229
|
|
|
218
230
|
- `approve`, `write` and `redo` need `--quoted-credits <n>` (the price `film
|
|
@@ -245,6 +257,15 @@ makemidas film download <id> --pieces -o ./cut # clips, audio, timeline.jso
|
|
|
245
257
|
voiceover and the music with a `timeline.json` (start, duration and local
|
|
246
258
|
file of each piece) for your own ffmpeg cut or an agent's. A talking clip
|
|
247
259
|
already carries its line: use its sound or the voiceover, not both.
|
|
260
|
+
- `film edit` writes `film-<id8>-edit/`, a [HyperFrames](https://hyperframes.heygen.com)
|
|
261
|
+
project of a finished film: the pieces under `assets/`, `kit.json` (the
|
|
262
|
+
timeline, each voiceover's words and when each is heard) and an
|
|
263
|
+
`index.html` that plays each shot with a slow push-in (a shot whose line
|
|
264
|
+
runs long plays slower and holds its last frame instead of freezing),
|
|
265
|
+
captions that pop in a few words at a time with the spoken word in gold,
|
|
266
|
+
and the music under the voice. `npm run render` makes `renders/film.mp4`
|
|
267
|
+
on your computer (Node.js 22+ and FFmpeg; nothing is charged); edit
|
|
268
|
+
`index.html`, or ask your agent, to change captions, timing or the mix.
|
|
248
269
|
- The storyboard file for `film update --file` is a JSON list of shots (or
|
|
249
270
|
`{ "shots": [...] }`), each with `prompt` and `duration`, and optionally
|
|
250
271
|
`id` (keep a shot and its frame), `type` (`normal` or `talking`),
|
package/dist/api.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
1
2
|
import { readFile } from 'node:fs/promises';
|
|
2
3
|
import { basename, extname } from 'node:path';
|
|
3
4
|
import { accessToken, envCredential } from "./auth.js";
|
|
4
5
|
import { USER_AGENT } from "./config.js";
|
|
5
6
|
import { CliError, EXIT, exitCodeFor } from "./errors.js";
|
|
7
|
+
import { log } from "./output.js";
|
|
6
8
|
export const KINDS = [
|
|
7
9
|
'image',
|
|
8
10
|
'video',
|
|
@@ -61,10 +63,23 @@ const MEDIA_UPLOADS = {
|
|
|
61
63
|
},
|
|
62
64
|
};
|
|
63
65
|
const isUrl = (source) => /^https?:\/\//i.test(source);
|
|
66
|
+
/** Waits before asking again for a generation whose answer was lost. */
|
|
67
|
+
export const GENERATE_RETRY_MS = [2000, 5000, 10000];
|
|
68
|
+
/**
|
|
69
|
+
* Errors after which the same request, with the same Idempotency-Key, can
|
|
70
|
+
* be sent again without a second charge: no answer, a server error, or the
|
|
71
|
+
* first attempt still starting.
|
|
72
|
+
*/
|
|
73
|
+
function retriesSafely(error) {
|
|
74
|
+
return (error instanceof CliError &&
|
|
75
|
+
(error.exitCode === EXIT.NETWORK || error.code === 'idempotency_in_progress'));
|
|
76
|
+
}
|
|
64
77
|
export class Api {
|
|
65
78
|
baseUrl;
|
|
66
79
|
/** Overridable in tests. */
|
|
67
80
|
fetchImpl = (...args) => fetch(...args);
|
|
81
|
+
/** Overridable in tests. */
|
|
82
|
+
sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
68
83
|
constructor(baseUrl) {
|
|
69
84
|
this.baseUrl = baseUrl;
|
|
70
85
|
}
|
|
@@ -241,11 +256,33 @@ export class Api {
|
|
|
241
256
|
},
|
|
242
257
|
});
|
|
243
258
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
259
|
+
/**
|
|
260
|
+
* Start a generation. Every attempt sends the same Idempotency-Key, so
|
|
261
|
+
* when the answer is lost (a dropped connection, a server error) asking
|
|
262
|
+
* again answers the generation the first attempt started instead of
|
|
263
|
+
* starting, and charging for, another.
|
|
264
|
+
*/
|
|
265
|
+
async generate(input, key = randomUUID()) {
|
|
266
|
+
for (let attempt = 0;; attempt++) {
|
|
267
|
+
try {
|
|
268
|
+
return await this.json('/generations', {
|
|
269
|
+
method: 'POST',
|
|
270
|
+
json: input,
|
|
271
|
+
headers: { 'Idempotency-Key': key },
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
if (!retriesSafely(error))
|
|
276
|
+
throw error;
|
|
277
|
+
const delay = GENERATE_RETRY_MS[attempt];
|
|
278
|
+
if (delay === undefined) {
|
|
279
|
+
const last = error;
|
|
280
|
+
throw new CliError(`${last.message}. It may have started anyway: look for it with \`makemidas list\` before running this again.`, last.exitCode, last.code, last.details);
|
|
281
|
+
}
|
|
282
|
+
log(`No answer yet (${error.message}); asking again in ${delay / 1000} s with the same request key, so nothing is charged twice…`);
|
|
283
|
+
await this.sleep(delay);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
249
286
|
}
|
|
250
287
|
/** Price a request without charging or creating anything. */
|
|
251
288
|
estimate(input) {
|
|
@@ -276,6 +313,10 @@ export class Api {
|
|
|
276
313
|
json: input,
|
|
277
314
|
});
|
|
278
315
|
}
|
|
316
|
+
/** Grants, charges and refunds, newest first. */
|
|
317
|
+
creditActivity(query) {
|
|
318
|
+
return this.json('/credits/activity', { query });
|
|
319
|
+
}
|
|
279
320
|
purchaseLink() {
|
|
280
321
|
return this.json('/credits/purchase-link');
|
|
281
322
|
}
|
|
@@ -359,6 +400,10 @@ export class Api {
|
|
|
359
400
|
film(id) {
|
|
360
401
|
return this.json(`/films/${encodeURIComponent(id)}`);
|
|
361
402
|
}
|
|
403
|
+
/** A finished film's edit kit; 409 until every piece is made. */
|
|
404
|
+
filmEditKit(id) {
|
|
405
|
+
return this.json(`/films/${encodeURIComponent(id)}/edit-kit`);
|
|
406
|
+
}
|
|
362
407
|
/** A new project from a brief; nothing is charged. */
|
|
363
408
|
createFilm(input) {
|
|
364
409
|
return this.json('/films', { method: 'POST', json: input });
|
package/dist/args.js
CHANGED
|
@@ -405,11 +405,11 @@ export function compareOptions(v) {
|
|
|
405
405
|
'format',
|
|
406
406
|
], 'compare');
|
|
407
407
|
}
|
|
408
|
-
const FEEDBACK_KINDS = ['bug', 'feature', 'praise', 'other'];
|
|
408
|
+
const FEEDBACK_KINDS = ['bug', 'quality', 'feature', 'praise', 'other'];
|
|
409
409
|
export function feedbackKind(value) {
|
|
410
410
|
const kind = value ?? 'other';
|
|
411
411
|
if (!FEEDBACK_KINDS.includes(kind)) {
|
|
412
|
-
throw usageError('--kind must be bug, feature, praise or other.');
|
|
412
|
+
throw usageError('--kind must be bug, quality, feature, praise or other.');
|
|
413
413
|
}
|
|
414
414
|
return kind;
|
|
415
415
|
}
|
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Api, KINDS } from "./api.js";
|
|
3
3
|
import { audioInput, compareModels, compareOptions, editInput, filmSeconds, filmSettings, feedbackKind, generationInput, intOption, parse, renderBrand, renderOptions, sourceArg, templateValues, transcriptionInput, usageError, } from "./args.js";
|
|
4
4
|
import * as commands from "./commands.js";
|
|
5
|
+
import { filmEdit } from "./film-edit.js";
|
|
5
6
|
import * as films from "./films.js";
|
|
6
7
|
import * as templates from "./templates.js";
|
|
7
8
|
import { resolveBaseUrl, VERSION } from "./config.js";
|
|
@@ -36,6 +37,9 @@ Usage:
|
|
|
36
37
|
makemidas assets upload <file|url>… Keep files in the asset library (--name, --tag)
|
|
37
38
|
makemidas assets delete <id> [--yes] Remove a file from the library
|
|
38
39
|
makemidas credits Credit balance and plan
|
|
40
|
+
makemidas credits activity Grants, charges and refunds, newest first
|
|
41
|
+
(--generation <id> for one generation's,
|
|
42
|
+
--limit, --before)
|
|
39
43
|
makemidas credits buy Links and prices for plans and credit packs
|
|
40
44
|
makemidas estimate <command> "<prompt>|<file>"
|
|
41
45
|
Price a request without charging: image,
|
|
@@ -44,7 +48,7 @@ Usage:
|
|
|
44
48
|
makemidas models [<kind>] Models, options and credit prices; kind is
|
|
45
49
|
image, video, audio, transcription or edit
|
|
46
50
|
makemidas models <id> One model: options, defaults, prices
|
|
47
|
-
makemidas feedback "<message>" Send feedback (--kind bug|feature|praise|other,
|
|
51
|
+
makemidas feedback "<message>" Send feedback (--kind bug|quality|feature|praise|other,
|
|
48
52
|
--generation <id>)
|
|
49
53
|
|
|
50
54
|
HTML templates (exact text: OG images, quote cards, lower thirds, title cards;
|
|
@@ -82,6 +86,9 @@ and music → one film; each paid stage is approved at the credits shown):
|
|
|
82
86
|
makemidas film download <id> [--pieces]
|
|
83
87
|
The film, or every clip, voiceover and the
|
|
84
88
|
music with timeline.json to cut it yourself
|
|
89
|
+
makemidas film edit <id> A HyperFrames project of the finished film
|
|
90
|
+
(word-by-word captions, slow push-ins) to
|
|
91
|
+
render and edit on this computer, free
|
|
85
92
|
makemidas film delete <id> [--yes] Delete the project (its generations stay)
|
|
86
93
|
|
|
87
94
|
Generation options (image, video, estimate):
|
|
@@ -442,7 +449,15 @@ async function main(argv) {
|
|
|
442
449
|
return commands.credits(api, g);
|
|
443
450
|
if (sub === 'buy' || sub === 'link')
|
|
444
451
|
return commands.creditsLink(api, g);
|
|
445
|
-
|
|
452
|
+
if (sub === 'activity' || sub === 'history') {
|
|
453
|
+
return commands.creditActivity(api, g, {
|
|
454
|
+
limit: intOption(v.limit === '20' ? undefined : v.limit, 'limit', 1, 100) ??
|
|
455
|
+
20,
|
|
456
|
+
...(v.before ? { before: v.before } : {}),
|
|
457
|
+
...(v.generation ? { generationId: v.generation } : {}),
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
throw usageError('Use `credits`, `credits activity` or `credits buy`.');
|
|
446
461
|
}
|
|
447
462
|
case 'estimate': {
|
|
448
463
|
const [kind, ...args] = rest;
|
|
@@ -541,13 +556,15 @@ async function main(argv) {
|
|
|
541
556
|
return films.filmAssemble(api, g, id, save, filmWait);
|
|
542
557
|
case 'download':
|
|
543
558
|
return films.filmDownload(api, g, id, save, { pieces: v.pieces });
|
|
559
|
+
case 'edit':
|
|
560
|
+
return filmEdit(api, g, films.need(id, 'a film id: `makemidas film edit <id>`'), { ...save, out: save.out ?? '.' });
|
|
544
561
|
case 'delete':
|
|
545
562
|
return films.filmDelete(api, g, id, {
|
|
546
563
|
yes: v.yes,
|
|
547
564
|
interactive: Boolean(process.stdin.isTTY),
|
|
548
565
|
});
|
|
549
566
|
default:
|
|
550
|
-
throw usageError('Use `film new`, `list`, `get`, `write`, `update`, `approve`, `redo`, `resume`, `assemble`, `download` or `delete`.');
|
|
567
|
+
throw usageError('Use `film new`, `list`, `get`, `write`, `update`, `approve`, `redo`, `resume`, `assemble`, `download`, `edit` or `delete`.');
|
|
551
568
|
}
|
|
552
569
|
}
|
|
553
570
|
default:
|
package/dist/commands.js
CHANGED
|
@@ -353,6 +353,54 @@ export async function credits(api, g) {
|
|
|
353
353
|
print(` ${item.amount} expire ${item.expiresAt.slice(0, 10)}`);
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
|
+
/** How many pages `credits activity --generation` looks through. */
|
|
357
|
+
const ACTIVITY_SCAN_PAGES = 5;
|
|
358
|
+
/**
|
|
359
|
+
* The credit history, newest first: grants, charges and refunds. With
|
|
360
|
+
* `generationId`, only what that generation charged and refunded.
|
|
361
|
+
*/
|
|
362
|
+
export async function creditActivity(api, g, opts) {
|
|
363
|
+
let entries;
|
|
364
|
+
let nextBefore;
|
|
365
|
+
if (opts.generationId) {
|
|
366
|
+
entries = [];
|
|
367
|
+
nextBefore = opts.before ?? null;
|
|
368
|
+
for (let page = 0; page < ACTIVITY_SCAN_PAGES; page++) {
|
|
369
|
+
const result = await api.creditActivity({
|
|
370
|
+
limit: 100,
|
|
371
|
+
...(nextBefore ? { before: nextBefore } : {}),
|
|
372
|
+
});
|
|
373
|
+
entries.push(...result.entries.filter((e) => e.generationId === opts.generationId));
|
|
374
|
+
nextBefore = result.nextBefore;
|
|
375
|
+
if (!nextBefore)
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
({ entries, nextBefore } = await api.creditActivity({
|
|
381
|
+
limit: opts.limit,
|
|
382
|
+
...(opts.before ? { before: opts.before } : {}),
|
|
383
|
+
}));
|
|
384
|
+
}
|
|
385
|
+
if (g.json) {
|
|
386
|
+
printJson({ entries, nextBefore });
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
if (!entries.length) {
|
|
390
|
+
print(opts.generationId
|
|
391
|
+
? `No charges or refunds found for ${opts.generationId}.`
|
|
392
|
+
: 'No credit activity yet.');
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
for (const e of entries) {
|
|
396
|
+
const credits = e.credits > 0 ? `+${e.credits}` : String(e.credits);
|
|
397
|
+
const what = [e.source, e.model, e.generationId].filter(Boolean).join(' ');
|
|
398
|
+
print(`${e.at.slice(0, 16).replace('T', ' ')} ${e.type.padEnd(6)} ${credits.padStart(6)} ${what}`);
|
|
399
|
+
}
|
|
400
|
+
if (nextBefore && !opts.generationId) {
|
|
401
|
+
print(`Older: makemidas credits activity --before ${nextBefore}`);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
356
404
|
export async function models(api, g, kind) {
|
|
357
405
|
const result = await api.models(kind);
|
|
358
406
|
if (g.json) {
|
package/dist/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
export const VERSION = '0.
|
|
4
|
+
export const VERSION = '0.6.0';
|
|
5
5
|
export const USER_AGENT = `makemidas-cli/${VERSION}`;
|
|
6
6
|
export const DEFAULT_BASE_URL = 'https://makemidas.com';
|
|
7
7
|
export function resolveBaseUrl(flag) {
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { copyFile, mkdir } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { writeOutput } from "./commands.js";
|
|
5
|
+
import { log, print, printJson } from "./output.js";
|
|
6
|
+
/*
|
|
7
|
+
* `makemidas film edit <id>`: a finished film as a HyperFrames project
|
|
8
|
+
* (https://hyperframes.heygen.com) an agent or a person renders and keeps
|
|
9
|
+
* editing on their own computer. The service sends the edit kit: every
|
|
10
|
+
* clip, voiceover line and the music on one timeline, each line's words
|
|
11
|
+
* with the time each is heard, and caption groups. This writes the pieces
|
|
12
|
+
* under assets/ and an index.html that plays them with a slow push-in on
|
|
13
|
+
* every shot (held shots play slower rather than freeze), captions that pop
|
|
14
|
+
* in a few words at a time with the spoken word lit, and the music under
|
|
15
|
+
* the voice. Nothing here is charged.
|
|
16
|
+
*/
|
|
17
|
+
/** The HyperFrames release the project's scripts pin, for repeatable renders. */
|
|
18
|
+
export const HYPERFRAMES_VERSION = '0.10.11';
|
|
19
|
+
const GSAP_URL = 'https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js';
|
|
20
|
+
/** The caption look: white words, the spoken one in gold. */
|
|
21
|
+
export const CAPTION_COLORS = { ink: '#ffffff', lit: '#FFC83D' };
|
|
22
|
+
const WIDE = /[⺀-鿿가-豈-︰-﹏-]/;
|
|
23
|
+
const EXT = {
|
|
24
|
+
'video/mp4': 'mp4',
|
|
25
|
+
'video/quicktime': 'mov',
|
|
26
|
+
'audio/mpeg': 'mp3',
|
|
27
|
+
'audio/wav': 'wav',
|
|
28
|
+
'audio/x-wav': 'wav',
|
|
29
|
+
'audio/mp4': 'm4a',
|
|
30
|
+
};
|
|
31
|
+
function r(value) {
|
|
32
|
+
return Math.round(value * 1000) / 1000;
|
|
33
|
+
}
|
|
34
|
+
function escapeHtml(text) {
|
|
35
|
+
return text
|
|
36
|
+
.replace(/&/g, '&')
|
|
37
|
+
.replace(/</g, '<')
|
|
38
|
+
.replace(/>/g, '>')
|
|
39
|
+
.replace(/"/g, '"')
|
|
40
|
+
.replace(/'/g, ''');
|
|
41
|
+
}
|
|
42
|
+
/** Where captions sit: clear of the buttons short-video apps draw. */
|
|
43
|
+
function captionBox(width, height) {
|
|
44
|
+
if (width < height) {
|
|
45
|
+
// 9:16: the area TikTok, Reels and Shorts all leave clear.
|
|
46
|
+
return {
|
|
47
|
+
left: Math.round(width * 0.111),
|
|
48
|
+
width: Math.round(width * 0.611),
|
|
49
|
+
bottom: Math.round(height * 0.365),
|
|
50
|
+
size: Math.round(width * 0.08),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const square = width === height;
|
|
54
|
+
return {
|
|
55
|
+
left: Math.round(width * 0.12),
|
|
56
|
+
width: Math.round(width * 0.76),
|
|
57
|
+
bottom: Math.round(height * (square ? 0.16 : 0.1)),
|
|
58
|
+
size: Math.round(Math.min(width, height) * (square ? 0.075 : 0.065)),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** The composition: the film as HyperFrames HTML. Pure. */
|
|
62
|
+
export function compositionHtml(kit, files) {
|
|
63
|
+
const { width: W, height: H } = kit;
|
|
64
|
+
const total = r(kit.seconds);
|
|
65
|
+
const shots = [];
|
|
66
|
+
const tweens = [];
|
|
67
|
+
const crossfade = kit.transition === 'crossfade';
|
|
68
|
+
kit.clips.forEach((clip, i) => {
|
|
69
|
+
const n = i + 1;
|
|
70
|
+
const held = clip.playbackRate < 1;
|
|
71
|
+
const push = held ? 1.1 : 1.06;
|
|
72
|
+
const drift = held ? 0 : [0, -2, 2][i % 3];
|
|
73
|
+
shots.push(`<div class="shot" id="s${n}"><div class="inner" data-layout-allow-overflow>` +
|
|
74
|
+
`<video id="v${n}" class="clip" src="${escapeHtml(files.clips[i])}" ` +
|
|
75
|
+
`data-start="${r(clip.start)}" data-duration="${r(clip.seconds)}" ` +
|
|
76
|
+
`data-playback-rate="${clip.playbackRate}" data-track-index="${n}" ` +
|
|
77
|
+
'muted playsinline></video></div></div>');
|
|
78
|
+
tweens.push(`tl.fromTo('#s${n} .inner', { scale: 1, xPercent: 0 }, { scale: ${push}, xPercent: ${drift}, duration: ${r(clip.seconds)}, ease: 'none' }, ${r(clip.start)});`);
|
|
79
|
+
if (crossfade && i > 0) {
|
|
80
|
+
const overlap = r(kit.clips[i - 1].start + kit.clips[i - 1].seconds - clip.start);
|
|
81
|
+
if (overlap > 0) {
|
|
82
|
+
tweens.push(`tl.fromTo('#s${n}', { opacity: 0 }, { opacity: 1, duration: ${overlap}, ease: 'none' }, ${r(clip.start)});`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const audio = kit.voiceover.map((line, i) => `<audio id="voice${i + 1}" src="${escapeHtml(files.voiceover[i])}" ` +
|
|
87
|
+
`data-start="${r(line.start)}" data-duration="${r(line.seconds)}" ` +
|
|
88
|
+
`data-track-index="${100 + i}" data-volume="1"></audio>`);
|
|
89
|
+
if (kit.music && files.music) {
|
|
90
|
+
const v = kit.music.volume;
|
|
91
|
+
const lane = {
|
|
92
|
+
version: 1,
|
|
93
|
+
lanes: [
|
|
94
|
+
{
|
|
95
|
+
target: 'volume',
|
|
96
|
+
points: [
|
|
97
|
+
{ t: 0, v: 0 },
|
|
98
|
+
{ t: 0.6, v },
|
|
99
|
+
{ t: r(Math.max(0.6, total - 1.2)), v },
|
|
100
|
+
{ t: total, v: 0 },
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
};
|
|
105
|
+
audio.push(`<audio id="music" src="${escapeHtml(files.music)}" data-start="0" ` +
|
|
106
|
+
`data-duration="${total}" data-track-index="99" ` +
|
|
107
|
+
`data-automation='${JSON.stringify(lane)}'></audio>`);
|
|
108
|
+
}
|
|
109
|
+
const box = captionBox(W, H);
|
|
110
|
+
const captions = [];
|
|
111
|
+
kit.captions.forEach((group, g) => {
|
|
112
|
+
const id = `c${g + 1}`;
|
|
113
|
+
const show = r(Math.max(0, group.start - 0.04));
|
|
114
|
+
const hide = r(Math.min(group.end - 0.04, total));
|
|
115
|
+
if (hide <= show)
|
|
116
|
+
return;
|
|
117
|
+
const words = group.words.map((word, w) => {
|
|
118
|
+
const gap = w > 0 &&
|
|
119
|
+
!(WIDE.test(group.words[w - 1].text.slice(-1)) && WIDE.test(word.text[0]))
|
|
120
|
+
? ' '
|
|
121
|
+
: '';
|
|
122
|
+
const wid = `${id}w${w}`;
|
|
123
|
+
const off = group.words[w + 1]?.start ?? word.end;
|
|
124
|
+
tweens.push(`tl.fromTo('#${wid}', { color: '${CAPTION_COLORS.ink}', scale: 1 }, { color: '${CAPTION_COLORS.lit}', scale: 1.1, duration: 0.07, ease: 'power2.out', immediateRender: false }, ${r(word.start)});`, `tl.fromTo('#${wid}', { color: '${CAPTION_COLORS.lit}', scale: 1.1 }, { color: '${CAPTION_COLORS.ink}', scale: 1, duration: 0.1, ease: 'power2.in', immediateRender: false }, ${r(off)});`);
|
|
125
|
+
return `${gap}<span class="w" id="${wid}">${escapeHtml(word.text)}</span>`;
|
|
126
|
+
});
|
|
127
|
+
captions.push(`<div class="cap clip" id="${id}" data-start="${show}" data-duration="${r(hide - show)}" data-track-index="200">` +
|
|
128
|
+
`<div class="cap-in" data-layout-allow-overlap>${words.join('')}</div></div>`);
|
|
129
|
+
tweens.push(`tl.fromTo('#${id} .cap-in', { scale: 0.72, y: ${Math.round(box.size * 0.28)}, opacity: 0 }, { scale: 1, y: 0, opacity: 1, duration: 0.16, ease: 'back.out(2.2)' }, ${show});`);
|
|
130
|
+
});
|
|
131
|
+
tweens.push(`tl.fromTo('#fade', { opacity: 0 }, { opacity: 1, duration: 0.35, ease: 'none' }, ${r(Math.max(0, total - 0.35))});`);
|
|
132
|
+
const indent = (lines, pad) => lines.map((line) => pad + line).join('\n');
|
|
133
|
+
return `<!doctype html>
|
|
134
|
+
<html lang="en">
|
|
135
|
+
<head>
|
|
136
|
+
<meta charset="UTF-8" />
|
|
137
|
+
<meta name="viewport" content="width=${W}, height=${H}" />
|
|
138
|
+
<title>${escapeHtml(kit.title)}</title>
|
|
139
|
+
<script src="${GSAP_URL}"></script>
|
|
140
|
+
<style>
|
|
141
|
+
@font-face { font-family: 'Inter'; font-weight: 900; src: url('assets/fonts/inter-latin-900-normal.woff2') format('woff2'); }
|
|
142
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
143
|
+
html, body { width: ${W}px; height: ${H}px; overflow: hidden; background: #000; }
|
|
144
|
+
#root { position: relative; width: ${W}px; height: ${H}px; }
|
|
145
|
+
.shot, .inner { position: absolute; inset: 0; overflow: hidden; }
|
|
146
|
+
.inner { transform-origin: 50% 40%; }
|
|
147
|
+
.inner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
|
|
148
|
+
/* Captions: edit the size, colours and place here. */
|
|
149
|
+
.cap { position: absolute; left: ${box.left}px; width: ${box.width}px; bottom: ${box.bottom}px; display: flex; justify-content: center; align-items: flex-end; }
|
|
150
|
+
.cap-in { text-align: center; font-family: 'Inter', sans-serif; font-weight: 900; font-size: ${box.size}px; line-height: 1.1; letter-spacing: -0.01em; color: ${CAPTION_COLORS.ink}; -webkit-text-stroke: ${Math.round(box.size * 0.15)}px #000; paint-order: stroke fill; text-shadow: 0 ${Math.round(box.size * 0.07)}px ${Math.round(box.size * 0.2)}px rgba(0, 0, 0, 0.55); }
|
|
151
|
+
.w { display: inline-block; transform-origin: 50% 70%; margin: 0 0.05em; }
|
|
152
|
+
#fade { position: absolute; inset: 0; background: #000; opacity: 0; }
|
|
153
|
+
</style>
|
|
154
|
+
</head>
|
|
155
|
+
<body>
|
|
156
|
+
<div id="root" data-composition-id="main" data-start="0" data-duration="${total}" data-width="${W}" data-height="${H}">
|
|
157
|
+
${indent(shots, ' ')}
|
|
158
|
+
${indent(captions, ' ')}
|
|
159
|
+
<div id="fade"></div>
|
|
160
|
+
${indent(audio, ' ')}
|
|
161
|
+
</div>
|
|
162
|
+
<script>
|
|
163
|
+
const tl = gsap.timeline({ paused: true });
|
|
164
|
+
${indent(tweens, ' ')}
|
|
165
|
+
window.__timelines['main'] = tl;
|
|
166
|
+
tl.seek(0);
|
|
167
|
+
</script>
|
|
168
|
+
</body>
|
|
169
|
+
</html>
|
|
170
|
+
`;
|
|
171
|
+
}
|
|
172
|
+
function projectPackage(name) {
|
|
173
|
+
const hf = `npx --yes hyperframes@${HYPERFRAMES_VERSION}`;
|
|
174
|
+
return `${JSON.stringify({
|
|
175
|
+
name,
|
|
176
|
+
private: true,
|
|
177
|
+
type: 'module',
|
|
178
|
+
scripts: {
|
|
179
|
+
check: `${hf} check`,
|
|
180
|
+
preview: `${hf} preview`,
|
|
181
|
+
render: `${hf} render --quality delivery -o renders/film.mp4`,
|
|
182
|
+
},
|
|
183
|
+
}, null, 2)}\n`;
|
|
184
|
+
}
|
|
185
|
+
const HYPERFRAMES_JSON = `${JSON.stringify({
|
|
186
|
+
$schema: 'https://hyperframes.heygen.com/schema/hyperframes.json',
|
|
187
|
+
paths: { assets: 'assets' },
|
|
188
|
+
media: { autoProxy: true },
|
|
189
|
+
}, null, 2)}\n`;
|
|
190
|
+
function readme(kit, dir) {
|
|
191
|
+
return `# ${kit.title}
|
|
192
|
+
|
|
193
|
+
A HyperFrames project of MakeMidas film ${kit.filmId}, made by \`makemidas film edit\`.
|
|
194
|
+
|
|
195
|
+
- \`npm run render\` makes \`renders/film.mp4\` (${kit.width}x${kit.height}, ${kit.seconds}s).
|
|
196
|
+
- \`npm run preview\` opens it in HyperFrames Studio; \`npm run check\` lints it.
|
|
197
|
+
- \`index.html\` is the film: each shot is a \`<video>\` with its start, length
|
|
198
|
+
and playback rate; captions are the \`.cap\` blocks, styled at the top of the
|
|
199
|
+
file; \`kit.json\` holds the timeline and each word's time.
|
|
200
|
+
- Ask your agent for changes in plain words ("bigger captions", "music
|
|
201
|
+
quieter", "cut shot 3 shorter"); the makemidas-film-edit skill knows this
|
|
202
|
+
layout.
|
|
203
|
+
|
|
204
|
+
Made in ${dir}.
|
|
205
|
+
`;
|
|
206
|
+
}
|
|
207
|
+
/** The fonts shipped with the CLI (OFL), for the captions. */
|
|
208
|
+
function fontsDir() {
|
|
209
|
+
return resolve(dirname(fileURLToPath(import.meta.url)), '..', 'fonts');
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Writes the HyperFrames project for film `id` into `<out>/film-<id>-edit/`
|
|
213
|
+
* and returns its directory and the files written.
|
|
214
|
+
*/
|
|
215
|
+
export async function writeEditProject(api, id, save) {
|
|
216
|
+
const kit = await api.filmEditKit(id);
|
|
217
|
+
const dir = resolve(save.out ?? '.', `film-${id.slice(0, 8)}-edit`);
|
|
218
|
+
await mkdir(join(dir, 'assets', 'fonts'), { recursive: true });
|
|
219
|
+
const written = [];
|
|
220
|
+
const fetchTo = async (url, name) => {
|
|
221
|
+
const { bytes, type } = await api.download(url);
|
|
222
|
+
const rel = `assets/${name}.${EXT[type.split(';')[0].trim()] ?? 'bin'}`;
|
|
223
|
+
if (await writeOutput(join(dir, rel), bytes, save.force)) {
|
|
224
|
+
written.push(join(dir, rel));
|
|
225
|
+
}
|
|
226
|
+
return rel;
|
|
227
|
+
};
|
|
228
|
+
log(`Downloading ${kit.clips.length} clips, ${kit.voiceover.length} voiceover lines${kit.music ? ' and the music' : ''}…`);
|
|
229
|
+
const files = { clips: [], voiceover: [], music: null };
|
|
230
|
+
let shot = 0;
|
|
231
|
+
for (const clip of kit.clips) {
|
|
232
|
+
const name = clip.kind === 'title_card'
|
|
233
|
+
? 'title-card'
|
|
234
|
+
: clip.kind === 'end_card'
|
|
235
|
+
? 'end-card'
|
|
236
|
+
: `clip-${++shot}`;
|
|
237
|
+
files.clips.push(await fetchTo(clip.url, name));
|
|
238
|
+
}
|
|
239
|
+
for (const [i, line] of kit.voiceover.entries()) {
|
|
240
|
+
files.voiceover.push(await fetchTo(line.url, `voice-${i + 1}`));
|
|
241
|
+
}
|
|
242
|
+
if (kit.music)
|
|
243
|
+
files.music = await fetchTo(kit.music.url, 'music');
|
|
244
|
+
for (const font of ['inter-latin-900-normal.woff2', 'OFL.txt']) {
|
|
245
|
+
await copyFile(join(fontsDir(), font), join(dir, 'assets', 'fonts', font));
|
|
246
|
+
}
|
|
247
|
+
const text = (name, body) => ({ name, body });
|
|
248
|
+
const local = {
|
|
249
|
+
...kit,
|
|
250
|
+
clips: kit.clips.map(({ url: _url, ...clip }, i) => ({ ...clip, file: files.clips[i] })),
|
|
251
|
+
voiceover: kit.voiceover.map(({ url: _url, ...line }, i) => ({
|
|
252
|
+
...line,
|
|
253
|
+
file: files.voiceover[i],
|
|
254
|
+
})),
|
|
255
|
+
music: kit.music && files.music ? { volume: kit.music.volume, file: files.music } : null,
|
|
256
|
+
};
|
|
257
|
+
for (const file of [
|
|
258
|
+
text('index.html', compositionHtml(kit, files)),
|
|
259
|
+
text('kit.json', `${JSON.stringify(local, null, 2)}\n`),
|
|
260
|
+
text('package.json', projectPackage(`film-${id.slice(0, 8)}`)),
|
|
261
|
+
text('hyperframes.json', HYPERFRAMES_JSON),
|
|
262
|
+
text('README.md', readme(kit, dir)),
|
|
263
|
+
]) {
|
|
264
|
+
const path = join(dir, file.name);
|
|
265
|
+
if (await writeOutput(path, new TextEncoder().encode(file.body), save.force)) {
|
|
266
|
+
written.push(path);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return { dir, files: written, kit };
|
|
270
|
+
}
|
|
271
|
+
export async function filmEdit(api, g, id, save) {
|
|
272
|
+
const { dir, files, kit } = await writeEditProject(api, id, save);
|
|
273
|
+
const next = [`cd ${JSON.stringify(dir)}`, 'npm run render'];
|
|
274
|
+
if (g.json) {
|
|
275
|
+
printJson({ id: kit.filmId, dir, files, seconds: kit.seconds, next });
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
print(dir);
|
|
279
|
+
log(`HyperFrames project ready (${kit.seconds}s, ${kit.captions.length} caption groups). Render it on this computer, free:\n ${next.join('\n ')}\nNeeds Node.js 22+ and FFmpeg; the first render downloads a headless Chrome.`);
|
|
280
|
+
}
|
package/dist/films.js
CHANGED
|
@@ -15,7 +15,7 @@ const WORKING = new Set(['making_frames', 'making_film', 'assembling']);
|
|
|
15
15
|
const POLL_SECONDS = { assembling: 8, other: 15 };
|
|
16
16
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
17
17
|
const short = (id) => id.slice(0, 8);
|
|
18
|
-
function need(value, what) {
|
|
18
|
+
export function need(value, what) {
|
|
19
19
|
if (!value)
|
|
20
20
|
throw new CliError(`Give ${what}.`, EXIT.USAGE, 'usage');
|
|
21
21
|
return value;
|
package/fonts/OFL.txt
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
https://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makemidas/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "AI image, video and audio generation CLI for AI agents (Claude Code, Cursor, Codex) and people: Nano Banana, GPT Image, Seedream, Seedance, Kling, Veo, Suno and more, plus talking avatars, HTML templates and short films, through MakeMidas.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-image-generator",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"makemidas": "dist/cli.js"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
|
-
"dist"
|
|
43
|
+
"dist",
|
|
44
|
+
"fonts"
|
|
44
45
|
],
|
|
45
46
|
"engines": {
|
|
46
47
|
"node": ">=20"
|