@makemidas/cli 0.3.1 → 0.5.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 +115 -11
- package/dist/api.js +96 -3
- package/dist/args.js +216 -2
- package/dist/cli.js +175 -6
- package/dist/commands.js +3 -3
- package/dist/config.js +1 -1
- package/dist/film-edit.js +280 -0
- package/dist/films.js +33 -8
- package/dist/templates.js +232 -0
- package/fonts/OFL.txt +93 -0
- package/fonts/inter-latin-900-normal.woff2 +0 -0
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
# MakeMidas CLI: AI image and
|
|
1
|
+
# MakeMidas CLI: AI image, video and audio generation for AI agents
|
|
2
2
|
|
|
3
3
|
An AI image, video and audio generation CLI for Claude Code, Cursor, Codex,
|
|
4
4
|
Gemini CLI, OpenClaw and people at a terminal. One command reaches Nano
|
|
5
5
|
Banana, GPT Image, Seedream, Flux, Seedance, Kling, Veo, Wan, Suno, Lyria,
|
|
6
6
|
Gemini TTS, Whisper and more through [MakeMidas](https://makemidas.com), paid
|
|
7
7
|
with your MakeMidas credits. It also transcribes audio, removes backgrounds,
|
|
8
|
-
upscales images and videos,
|
|
8
|
+
upscales images and videos, lip-syncs talking avatars, renders HTML
|
|
9
|
+
templates and your own HTML to images and videos, makes short films from a
|
|
10
|
+
brief, and compares image models side by side. Coding
|
|
9
11
|
agents run it like any other command; the
|
|
10
12
|
[agent skill](https://github.com/makemidas-ai/skills) teaches them the
|
|
11
13
|
options, and the same account works in ChatGPT and Claude through the
|
|
@@ -18,6 +20,8 @@ makemidas image "a lighthouse at dawn, film photo" --aspect 16:9
|
|
|
18
20
|
makemidas video "the waves roll in" --ref lighthouse.png --duration 5
|
|
19
21
|
makemidas speech "Welcome back." --delivery "warm and unhurried"
|
|
20
22
|
makemidas transcribe interview.m4a --format srt
|
|
23
|
+
makemidas render quote-card --set quote="Make it simple." --set author=Ada
|
|
24
|
+
makemidas film new "a 15-second social video for our mugs" --style social --max-credits 30
|
|
21
25
|
```
|
|
22
26
|
|
|
23
27
|
## Commands
|
|
@@ -36,9 +40,15 @@ makemidas transcribe interview.m4a --format srt
|
|
|
36
40
|
| `remove-bg <image>` | Remove the background; saves a transparent WebP |
|
|
37
41
|
| `upscale <image> [--scale 1\|2\|4\|8]` | Upscale an image (1 sharpens at the same size; default 2) |
|
|
38
42
|
| `upscale-video <video> [--resolution 1080P\|2K\|4K]` | Upscale an MP4 or MOV clip of up to 60 s (default 2K) |
|
|
43
|
+
| `avatar <photo> <voice>` | Lip-sync a portrait to a voice track (a talking avatar video); `--character <id>` in place of the photo ([below](#talking-avatars)) |
|
|
39
44
|
| `compare "<prompt>" --models a,b[,c,d]` | One prompt on 2–4 image models, one image each |
|
|
45
|
+
| `templates [<category>]`, `template <id>` | HTML templates (built-in and saved), their fields and today's free renders |
|
|
46
|
+
| `render <id> --set f=v…` | Fill a template and save the image, or `--video` for an animated one ([below](#templates-and-your-own-html)) |
|
|
47
|
+
| `html <page.html\|->` | Render your own HTML and CSS to an image, or `--video` to play its CSS animations |
|
|
48
|
+
| `template save\|update\|delete …` | Keep your own page as a template with fill-in fields |
|
|
40
49
|
| `film new "<brief>"`, `film get/approve/redo/download …` | Film projects: script and storyboard, approved frames and clips, an assembled film ([below](#film-projects)) |
|
|
41
50
|
| `brands [<id>\|default]`, `characters`, `assets [--q] [--kind]` | Saved brands (with their guidelines), characters and asset-library files to build on |
|
|
51
|
+
| `assets upload <file\|url>… [--name] [--tag t]`, `assets delete <id>` | Keep files in the asset library, or remove one |
|
|
42
52
|
| `get <id> [--wait]` | Fetch a generation and save its files |
|
|
43
53
|
| `list [--limit n] [--before t]` | Recent generations |
|
|
44
54
|
| `delete <id> [--yes]` | Delete a finished or failed generation and its files (no refund) |
|
|
@@ -46,7 +56,7 @@ makemidas transcribe interview.m4a --format srt
|
|
|
46
56
|
| `credits buy` (or `credits link`) | Links to buy a plan or credit pack, with prices; opens nothing |
|
|
47
57
|
| `models [image\|video\|audio\|transcription\|edit]` | Model ids, options and credit prices |
|
|
48
58
|
| `models <id>` | One model: options, defaults, voices, prices and an example request |
|
|
49
|
-
| `estimate <command> "<prompt>"\|<file>` | Price a request without charging; `<command>` is `image`, `video`, `music`, `sfx`, `speech`, `transcribe`, `remove-bg`, `upscale` or `
|
|
59
|
+
| `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 |
|
|
50
60
|
| `feedback "<message>" [--kind bug\|feature\|praise\|other] [--generation <id>]` | Send feedback to the MakeMidas team |
|
|
51
61
|
|
|
52
62
|
Common options: `--model`, `--aspect`, `--resolution`, `--count`, `--ref`
|
|
@@ -96,6 +106,68 @@ stdin is not a terminal), 3 not signed in, 4 not enough credits, a plan
|
|
|
96
106
|
limit or busy (also over `--max-credits`), 5 generation failed (credits
|
|
97
107
|
refunded), 6 network or server error, 7 still rendering.
|
|
98
108
|
|
|
109
|
+
## Talking avatars
|
|
110
|
+
|
|
111
|
+
`avatar` turns one portrait photo and a voice track into a lip-synced video
|
|
112
|
+
as long as the track, billed per second of it:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
makemidas speech "Hi, I'm Ada. Let me show you around." --voice Kore -o .
|
|
116
|
+
makemidas avatar ada.png makemidas-<id>-1.wav -r 720p --direction "smiles, nods once"
|
|
117
|
+
makemidas avatar line.mp3 --character <id> --max-credits 60
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The voice track (MP3, WAV, M4A, AAC or OGG, up to 50 MB and 5 minutes, a
|
|
121
|
+
file or a link) is spoken exactly as given; make it with `makemidas speech`
|
|
122
|
+
when you have only a script. `-m kie/infinitetalk` takes up to 15 seconds at
|
|
123
|
+
480p or 720p, `-m kwaivgi/kling-ai-avatar` up to 5 minutes at 720p; left
|
|
124
|
+
out, the first model on sale is used (`makemidas models edit`).
|
|
125
|
+
`--direction` describes expression and movement. `makemidas estimate avatar
|
|
126
|
+
<photo> <voice>` prices it first.
|
|
127
|
+
|
|
128
|
+
## Templates and your own HTML
|
|
129
|
+
|
|
130
|
+
Image models get text wrong; templates don't. Built-in templates make quote
|
|
131
|
+
cards, announcement posts, link preview (OG) images, product promos, title
|
|
132
|
+
cards, transparent lower thirds and stat cards, filled with your default
|
|
133
|
+
brand's colors, fonts and logo:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
makemidas templates # ids, sizes, free renders left today
|
|
137
|
+
makemidas template quote-card # its fields, as --set lines
|
|
138
|
+
makemidas render quote-card --set quote="Make it simple." --set author=Ada --size portrait
|
|
139
|
+
makemidas render og-image --set title="Launch week" --brand none --format webp
|
|
140
|
+
makemidas render lower-third --set name=Ada --video --format mov # keeps transparency
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`--set field=value` takes text as written; image fields take
|
|
144
|
+
`asset:<id>`, `generation:<id>[/<n>]`, `background:<id>` (built-in photos a
|
|
145
|
+
field lists), `brand-image:<id>`, or a local JPG, PNG or WebP, which is
|
|
146
|
+
kept in your asset library first. An empty value clears a field.
|
|
147
|
+
|
|
148
|
+
Your own page renders the same way: no JavaScript runs, images are data
|
|
149
|
+
URLs or your files as `asset:<id>` / `generation:<id>`, fonts come from
|
|
150
|
+
Google Fonts, and every other URL is removed.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
makemidas html card.html --css card.css --size og
|
|
154
|
+
makemidas html intro.html --video --seconds 6 --size landscape # CSS animations
|
|
155
|
+
makemidas template save card.html --name "Launch card" --fields fields.json --width 1200 --height 630
|
|
156
|
+
makemidas render <saved-id> --set title="Spring sale"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
A saved template's fields fill its placeholders: a text field the element
|
|
160
|
+
with `data-var-text="<id>"`, an image field `<img data-var-src="<id>">`, a
|
|
161
|
+
color field the CSS variable `--<id>`, a choice `data-<id>` on `<html>`.
|
|
162
|
+
`fields.json` is a list (or `{ "fields": [...] }`) of `{ "id", "type":
|
|
163
|
+
"text"|"color"|"image"|"choice", "label", "default", … }`; text fields
|
|
164
|
+
need `maxLength`, choices `options`.
|
|
165
|
+
|
|
166
|
+
The first image renders each UTC day are free (10, or 100 on a paid plan),
|
|
167
|
+
templates and HTML together, then 1 credit each. Videos (2–15 seconds, MP4,
|
|
168
|
+
or MOV for transparent templates; `--matte #rrggbb` sets what sits behind a
|
|
169
|
+
transparent page in an MP4) cost 1 credit per started 5 seconds.
|
|
170
|
+
|
|
99
171
|
## Brands, characters and the asset library
|
|
100
172
|
|
|
101
173
|
Images and videos can follow a saved brand and reuse saved characters and
|
|
@@ -107,6 +179,8 @@ makemidas image "our cold brew on a desk" --brand default --brand-logo
|
|
|
107
179
|
makemidas video "she waves at the camera" --character <id> -d 5
|
|
108
180
|
makemidas assets --q "product shot" --kind image
|
|
109
181
|
makemidas image "the same bottle on a beach" --ref asset:<id>
|
|
182
|
+
makemidas assets upload logo.png bottle.jpg --tag brand
|
|
183
|
+
makemidas assets delete <id> --yes
|
|
110
184
|
```
|
|
111
185
|
|
|
112
186
|
`--brand <id|default>` adds the brand's guidelines to the prompt (and, for
|
|
@@ -139,6 +213,10 @@ makemidas film approve <id> film --quoted-credits <n> --wait -o .
|
|
|
139
213
|
# Redo one piece, or take the pieces and cut it yourself
|
|
140
214
|
makemidas film redo <id> 2 clip --max-credits 40
|
|
141
215
|
makemidas film download <id> --pieces -o ./cut # clips, audio, timeline.json
|
|
216
|
+
|
|
217
|
+
# Re-cut a finished film on this computer: word-by-word captions, slow push-ins
|
|
218
|
+
makemidas film edit <id> -o . # a HyperFrames project
|
|
219
|
+
cd film-<id8>-edit && npm run render # renders/film.mp4, free
|
|
142
220
|
```
|
|
143
221
|
|
|
144
222
|
- `approve`, `write` and `redo` need `--quoted-credits <n>` (the price `film
|
|
@@ -149,22 +227,48 @@ makemidas film download <id> --pieces -o ./cut # clips, audio, timeline.jso
|
|
|
149
227
|
`--speech-model`, `--voice`, `--music-model <id|none>`, `--music-prompt`,
|
|
150
228
|
`--transition cut|fade|crossfade`, `--clip-audio`, `--brand <id|none>`. After
|
|
151
229
|
the film is approved only the voiceover model and voice can change.
|
|
230
|
+
- `--style social` writes a short vertical video to stop the scroll on
|
|
231
|
+
TikTok, Reels or Shorts (9:16, about 15 seconds and subtitles on by
|
|
232
|
+
default). `--subtitles on|off` burns the voiceover in as subtitles;
|
|
233
|
+
`--title-card` and `--end-card` take `on`, `off` or a title for an
|
|
234
|
+
animated card (1 credit per started 5 seconds, approved with the film);
|
|
235
|
+
`--lower-thirds on` shows each speaker's name the first time they speak.
|
|
236
|
+
- Cast: `--characters <id,…>` (up to 4 saved characters). A shot with
|
|
237
|
+
`"type": "talking"` and a `characterId` in the storyboard file has that
|
|
238
|
+
character say its voiceover to camera, lip-synced by `--avatar-model`
|
|
239
|
+
(priced per second of the line).
|
|
240
|
+
- With each storyboard the script model adds a self-check (the question the
|
|
241
|
+
opening raises, the shot that pays it off, the one surprise); read it with
|
|
242
|
+
`film get <id> --json` under `settings.storyboardCheck`.
|
|
152
243
|
- `--wait` follows the frames, the film and the assembly (`--timeout`,
|
|
153
244
|
default 15 minutes); it polls the assembly every 8 seconds, which keeps the
|
|
154
245
|
render moving. A paused project (out of credits) exits 4: top up, then
|
|
155
246
|
`makemidas film resume <id>`.
|
|
156
|
-
- `film download
|
|
157
|
-
`
|
|
158
|
-
|
|
247
|
+
- `film download` saves the film and, when it has subtitles, its `.srt`.
|
|
248
|
+
`--pieces` saves every clip (`title-card`, `clip-<n>`, `end-card`),
|
|
249
|
+
voiceover and the music with a `timeline.json` (start, duration and local
|
|
250
|
+
file of each piece) for your own ffmpeg cut or an agent's. A talking clip
|
|
251
|
+
already carries its line: use its sound or the voiceover, not both.
|
|
252
|
+
- `film edit` writes `film-<id8>-edit/`, a [HyperFrames](https://hyperframes.heygen.com)
|
|
253
|
+
project of a finished film: the pieces under `assets/`, `kit.json` (the
|
|
254
|
+
timeline, each voiceover's words and when each is heard) and an
|
|
255
|
+
`index.html` that plays each shot with a slow push-in (a shot whose line
|
|
256
|
+
runs long plays slower and holds its last frame instead of freezing),
|
|
257
|
+
captions that pop in a few words at a time with the spoken word in gold,
|
|
258
|
+
and the music under the voice. `npm run render` makes `renders/film.mp4`
|
|
259
|
+
on your computer (Node.js 22+ and FFmpeg; nothing is charged); edit
|
|
260
|
+
`index.html`, or ask your agent, to change captions, timing or the mix.
|
|
159
261
|
- The storyboard file for `film update --file` is a JSON list of shots (or
|
|
160
262
|
`{ "shots": [...] }`), each with `prompt` and `duration`, and optionally
|
|
161
|
-
`id` (keep a shot and its frame), `
|
|
263
|
+
`id` (keep a shot and its frame), `type` (`normal` or `talking`),
|
|
264
|
+
`description`, `camera`, `voiceover`, `characterId` and `assetIds`.
|
|
162
265
|
|
|
163
266
|
## Credits
|
|
164
267
|
|
|
165
|
-
Every generation spends credits at the same prices as the website.
|
|
166
|
-
|
|
167
|
-
|
|
268
|
+
Every generation spends credits at the same prices as the website. A new
|
|
269
|
+
account gets free credits once its email is verified; after that, credits
|
|
270
|
+
come from a monthly plan or a one-time credit pack (`makemidas credits buy`
|
|
271
|
+
prints the links and prices). `makemidas
|
|
168
272
|
models` shows the prices;
|
|
169
273
|
`--quoted-credits <n>` refuses to charge anything else.
|
|
170
274
|
|
|
@@ -184,7 +288,7 @@ makemidas estimate upscale-video clip.mp4 --resolution 4K
|
|
|
184
288
|
|
|
185
289
|
Or price and run in one step: `--max-credits <n>` on any generating command
|
|
186
290
|
(`image`, `video`, `music`, `sfx`, `speech`, `transcribe`, `remove-bg`,
|
|
187
|
-
`upscale`, `upscale-video`, `compare`) estimates first and stops (exit 4, nothing charged) when the request costs
|
|
291
|
+
`upscale`, `upscale-video`, `avatar`, `compare`) estimates first and stops (exit 4, nothing charged) when the request costs
|
|
188
292
|
more than `n` or more than your balance. Otherwise it sends the estimated
|
|
189
293
|
request back at exactly the quoted price, with reference images and files
|
|
190
294
|
uploaded once. `compare` prices each model and quotes the total:
|
package/dist/api.js
CHANGED
|
@@ -33,6 +33,20 @@ const AUDIO_TYPES = {
|
|
|
33
33
|
'.webm': 'audio/webm',
|
|
34
34
|
...VIDEO_TYPES,
|
|
35
35
|
};
|
|
36
|
+
/** Talking avatar voice tracks. */
|
|
37
|
+
const VOICE_TYPES = {
|
|
38
|
+
'.mp3': 'audio/mpeg',
|
|
39
|
+
'.wav': 'audio/wav',
|
|
40
|
+
'.m4a': 'audio/mp4',
|
|
41
|
+
'.aac': 'audio/aac',
|
|
42
|
+
'.ogg': 'audio/ogg',
|
|
43
|
+
'.oga': 'audio/ogg',
|
|
44
|
+
};
|
|
45
|
+
/** What the asset library keeps, by file extension. */
|
|
46
|
+
const ASSET_TYPES = {
|
|
47
|
+
...CONTENT_TYPES,
|
|
48
|
+
...AUDIO_TYPES,
|
|
49
|
+
};
|
|
36
50
|
const MEDIA_UPLOADS = {
|
|
37
51
|
audio: {
|
|
38
52
|
path: '/audio-uploads',
|
|
@@ -40,6 +54,11 @@ const MEDIA_UPLOADS = {
|
|
|
40
54
|
what: 'MP3, WAV, M4A, AAC, FLAC, OGG, Opus, WEBM, MP4 or MOV',
|
|
41
55
|
},
|
|
42
56
|
video: { path: '/video-uploads', types: VIDEO_TYPES, what: 'MP4 or MOV' },
|
|
57
|
+
voice: {
|
|
58
|
+
path: '/voice-uploads',
|
|
59
|
+
types: VOICE_TYPES,
|
|
60
|
+
what: 'MP3, WAV, M4A, AAC or OGG',
|
|
61
|
+
},
|
|
43
62
|
};
|
|
44
63
|
const isUrl = (source) => /^https?:\/\//i.test(source);
|
|
45
64
|
export class Api {
|
|
@@ -189,9 +208,9 @@ export class Api {
|
|
|
189
208
|
return id;
|
|
190
209
|
}
|
|
191
210
|
/**
|
|
192
|
-
* Upload audio or video to transcribe (`audio`),
|
|
193
|
-
* (`video`)
|
|
194
|
-
* the server to download.
|
|
211
|
+
* Upload audio or video to transcribe (`audio`), a video to upscale
|
|
212
|
+
* (`video`) or a talking avatar's voice track (`voice`): a local file goes
|
|
213
|
+
* as the raw body, a link as `{ url }` for the server to download.
|
|
195
214
|
*/
|
|
196
215
|
async mediaUpload(kind, source) {
|
|
197
216
|
const { path, types, what } = MEDIA_UPLOADS[kind];
|
|
@@ -263,6 +282,76 @@ export class Api {
|
|
|
263
282
|
async list(query) {
|
|
264
283
|
return (await this.json('/generations', { query })).generations;
|
|
265
284
|
}
|
|
285
|
+
// ---------------------------------------------------------------- assets
|
|
286
|
+
/**
|
|
287
|
+
* Keep a local file or a public link in the asset library; answers the
|
|
288
|
+
* asset (`deduped` when the same file was already kept).
|
|
289
|
+
*/
|
|
290
|
+
async uploadAsset(source, opts = {}) {
|
|
291
|
+
if (isUrl(source)) {
|
|
292
|
+
return this.json('/assets', {
|
|
293
|
+
method: 'POST',
|
|
294
|
+
json: {
|
|
295
|
+
url: source,
|
|
296
|
+
...(opts.name ? { name: opts.name } : {}),
|
|
297
|
+
...(opts.tags?.length ? { tags: opts.tags } : {}),
|
|
298
|
+
},
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
const type = ASSET_TYPES[extname(source).toLowerCase()];
|
|
302
|
+
if (!type) {
|
|
303
|
+
throw new CliError(`${source}: the asset library keeps JPG, PNG or WebP images, audio, and MP4 or MOV video.`, EXIT.USAGE, 'invalid_file');
|
|
304
|
+
}
|
|
305
|
+
let bytes;
|
|
306
|
+
try {
|
|
307
|
+
bytes = new Uint8Array(await readFile(source));
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
throw new CliError(`Can't read ${source}`, EXIT.USAGE, 'invalid_file');
|
|
311
|
+
}
|
|
312
|
+
const form = new FormData();
|
|
313
|
+
form.append('file', new Blob([bytes], { type }), opts.name ?? basename(source));
|
|
314
|
+
const saved = await this.json('/assets', { method: 'POST', form });
|
|
315
|
+
if (opts.tags?.length) {
|
|
316
|
+
saved.asset = await this.json(`/assets/${encodeURIComponent(saved.asset.id)}`, { method: 'PATCH', json: { tags: opts.tags } });
|
|
317
|
+
}
|
|
318
|
+
return saved;
|
|
319
|
+
}
|
|
320
|
+
async deleteAsset(id) {
|
|
321
|
+
await this.request(`/assets/${encodeURIComponent(id)}`, { method: 'DELETE' });
|
|
322
|
+
}
|
|
323
|
+
// ---------------------------------------------------------------- templates
|
|
324
|
+
templates(category) {
|
|
325
|
+
return this.json('/templates', { query: { category } });
|
|
326
|
+
}
|
|
327
|
+
template(id) {
|
|
328
|
+
return this.json(`/templates/${encodeURIComponent(id)}`);
|
|
329
|
+
}
|
|
330
|
+
saveTemplate(input) {
|
|
331
|
+
return this.json('/templates', { method: 'POST', json: input });
|
|
332
|
+
}
|
|
333
|
+
updateTemplate(id, input) {
|
|
334
|
+
return this.json(`/templates/${encodeURIComponent(id)}`, {
|
|
335
|
+
method: 'PATCH',
|
|
336
|
+
json: input,
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
async deleteTemplate(id) {
|
|
340
|
+
await this.request(`/templates/${encodeURIComponent(id)}`, {
|
|
341
|
+
method: 'DELETE',
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
/** An image, done within the request. */
|
|
345
|
+
render(input) {
|
|
346
|
+
return this.json('/renders', { method: 'POST', json: input });
|
|
347
|
+
}
|
|
348
|
+
/** A video; it answers while rendering, so read the generation until done. */
|
|
349
|
+
videoRender(input) {
|
|
350
|
+
return this.json('/video-renders', {
|
|
351
|
+
method: 'POST',
|
|
352
|
+
json: input,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
266
355
|
// ---------------------------------------------------------------- films
|
|
267
356
|
async films() {
|
|
268
357
|
return (await this.json('/films')).films;
|
|
@@ -270,6 +359,10 @@ export class Api {
|
|
|
270
359
|
film(id) {
|
|
271
360
|
return this.json(`/films/${encodeURIComponent(id)}`);
|
|
272
361
|
}
|
|
362
|
+
/** A finished film's edit kit; 409 until every piece is made. */
|
|
363
|
+
filmEditKit(id) {
|
|
364
|
+
return this.json(`/films/${encodeURIComponent(id)}/edit-kit`);
|
|
365
|
+
}
|
|
273
366
|
/** A new project from a brief; nothing is charged. */
|
|
274
367
|
createFilm(input) {
|
|
275
368
|
return this.json('/films', { method: 'POST', json: input });
|
package/dist/args.js
CHANGED
|
@@ -67,6 +67,25 @@ export function parse(argv) {
|
|
|
67
67
|
character: { type: 'string' },
|
|
68
68
|
'brand-logo': { type: 'boolean', default: false },
|
|
69
69
|
q: { type: 'string' },
|
|
70
|
+
direction: { type: 'string' },
|
|
71
|
+
set: { type: 'string', multiple: true, default: [] },
|
|
72
|
+
size: { type: 'string' },
|
|
73
|
+
width: { type: 'string' },
|
|
74
|
+
height: { type: 'string' },
|
|
75
|
+
css: { type: 'string' },
|
|
76
|
+
transparent: { type: 'boolean', default: false },
|
|
77
|
+
video: { type: 'boolean', default: false },
|
|
78
|
+
matte: { type: 'string' },
|
|
79
|
+
name: { type: 'string' },
|
|
80
|
+
description: { type: 'string' },
|
|
81
|
+
fields: { type: 'string' },
|
|
82
|
+
tag: { type: 'string', multiple: true, default: [] },
|
|
83
|
+
subtitles: { type: 'string' },
|
|
84
|
+
'title-card': { type: 'string' },
|
|
85
|
+
'end-card': { type: 'string' },
|
|
86
|
+
'lower-thirds': { type: 'string' },
|
|
87
|
+
characters: { type: 'string' },
|
|
88
|
+
'avatar-model': { type: 'string' },
|
|
70
89
|
},
|
|
71
90
|
});
|
|
72
91
|
}
|
|
@@ -287,8 +306,10 @@ export const EDIT_COMMANDS = {
|
|
|
287
306
|
'remove-background': 'remove-bg',
|
|
288
307
|
'upscale-image': 'upscale',
|
|
289
308
|
'upscale-video': 'upscale-video',
|
|
309
|
+
'talking-avatar': 'avatar',
|
|
290
310
|
};
|
|
291
311
|
const VIDEO_UPSCALE_RESOLUTIONS = ['1080P', '2K', '4K'];
|
|
312
|
+
const AVATAR_RESOLUTIONS = ['480p', '720p'];
|
|
292
313
|
/** A `makemidas remove-bg|upscale|upscale-video` request (kind edit). */
|
|
293
314
|
export function editInput(task, v) {
|
|
294
315
|
const command = EDIT_COMMANDS[task];
|
|
@@ -302,14 +323,38 @@ export function editInput(task, v) {
|
|
|
302
323
|
];
|
|
303
324
|
if (task !== 'upscale-image')
|
|
304
325
|
others.push('scale');
|
|
305
|
-
if (task !== 'upscale-video')
|
|
326
|
+
if (task !== 'upscale-video' && task !== 'talking-avatar') {
|
|
306
327
|
others.push('resolution');
|
|
307
|
-
|
|
328
|
+
}
|
|
329
|
+
if (task !== 'talking-avatar')
|
|
330
|
+
others.push('direction');
|
|
331
|
+
refuse(v, task === 'talking-avatar'
|
|
332
|
+
? others.filter((name) => name !== 'character')
|
|
333
|
+
: others, command);
|
|
308
334
|
const input = {
|
|
309
335
|
kind: 'edit',
|
|
310
336
|
task,
|
|
311
337
|
...(v.model ? { model: v.model } : {}),
|
|
312
338
|
};
|
|
339
|
+
if (task === 'talking-avatar') {
|
|
340
|
+
if (v.resolution !== undefined) {
|
|
341
|
+
const resolution = v.resolution.toLowerCase();
|
|
342
|
+
if (!AVATAR_RESOLUTIONS.includes(resolution)) {
|
|
343
|
+
throw usageError('--resolution must be 480p or 720p.');
|
|
344
|
+
}
|
|
345
|
+
input.resolution = resolution;
|
|
346
|
+
}
|
|
347
|
+
if (v.direction !== undefined) {
|
|
348
|
+
const direction = v.direction.trim();
|
|
349
|
+
if (direction.length > 1000) {
|
|
350
|
+
throw usageError('--direction is at most 1,000 characters.');
|
|
351
|
+
}
|
|
352
|
+
if (direction)
|
|
353
|
+
input.prompt = direction;
|
|
354
|
+
}
|
|
355
|
+
if (v.character)
|
|
356
|
+
input.characterId = v.character;
|
|
357
|
+
}
|
|
313
358
|
if (task === 'upscale-image' && v.scale !== undefined) {
|
|
314
359
|
const scale = Number(v.scale.replace(/x$/i, ''));
|
|
315
360
|
if (![1, 2, 4, 8].includes(scale)) {
|
|
@@ -405,9 +450,178 @@ export function filmSettings(v) {
|
|
|
405
450
|
}
|
|
406
451
|
settings.transition = v.transition;
|
|
407
452
|
}
|
|
453
|
+
if (v.style) {
|
|
454
|
+
if (v.style !== 'film' && v.style !== 'social') {
|
|
455
|
+
throw usageError('--style must be film or social (a short vertical video for TikTok, Reels or Shorts).');
|
|
456
|
+
}
|
|
457
|
+
settings.style = v.style;
|
|
458
|
+
}
|
|
459
|
+
if (v.subtitles !== undefined)
|
|
460
|
+
settings.subtitles = onOff(v.subtitles, 'subtitles');
|
|
461
|
+
if (v['lower-thirds'] !== undefined) {
|
|
462
|
+
settings.lowerThirds = onOff(v['lower-thirds'], 'lower-thirds');
|
|
463
|
+
}
|
|
464
|
+
if (v['title-card'] !== undefined) {
|
|
465
|
+
settings.titleCard = filmCard(v['title-card']);
|
|
466
|
+
}
|
|
467
|
+
if (v['end-card'] !== undefined)
|
|
468
|
+
settings.endCard = filmCard(v['end-card']);
|
|
469
|
+
if (v.characters !== undefined) {
|
|
470
|
+
settings.characterIds =
|
|
471
|
+
v.characters === 'none'
|
|
472
|
+
? []
|
|
473
|
+
: v.characters
|
|
474
|
+
.split(',')
|
|
475
|
+
.map((id) => id.trim())
|
|
476
|
+
.filter(Boolean);
|
|
477
|
+
if (settings.characterIds.length > 4) {
|
|
478
|
+
throw usageError('--characters takes up to 4 character ids.');
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (v['avatar-model'])
|
|
482
|
+
settings.avatarModel = v['avatar-model'];
|
|
408
483
|
return settings;
|
|
409
484
|
}
|
|
485
|
+
function onOff(value, name) {
|
|
486
|
+
const lower = value.toLowerCase();
|
|
487
|
+
if (lower === 'on' || lower === 'true' || lower === 'yes')
|
|
488
|
+
return true;
|
|
489
|
+
if (lower === 'off' || lower === 'false' || lower === 'no')
|
|
490
|
+
return false;
|
|
491
|
+
throw usageError(`--${name} must be on or off.`);
|
|
492
|
+
}
|
|
493
|
+
/** `--title-card on|off|"<title>"`: the default card, none, or one with that title. */
|
|
494
|
+
function filmCard(value) {
|
|
495
|
+
const lower = value.trim().toLowerCase();
|
|
496
|
+
if (lower === 'off' || lower === 'none')
|
|
497
|
+
return null;
|
|
498
|
+
if (lower === 'on' || lower === 'yes')
|
|
499
|
+
return {};
|
|
500
|
+
if (value.trim().length > 80) {
|
|
501
|
+
throw usageError('A card title is at most 80 characters.');
|
|
502
|
+
}
|
|
503
|
+
return { title: value.trim() };
|
|
504
|
+
}
|
|
410
505
|
/** About how long the film should be, in seconds. */
|
|
411
506
|
export function filmSeconds(v) {
|
|
412
507
|
return intOption(v.seconds, 'seconds', 10, 120);
|
|
413
508
|
}
|
|
509
|
+
// ---------------------------------------------------------------- templates
|
|
510
|
+
const TEMPLATE_SIZES = ['square', 'portrait', 'story', 'landscape', 'og'];
|
|
511
|
+
const IMAGE_FILE = /\.(jpe?g|png|webp)$/i;
|
|
512
|
+
/**
|
|
513
|
+
* One `--set field=value`: text as given; `asset:<id>`,
|
|
514
|
+
* `generation:<id>[/<n>]`, `background:<id>` and `brand-image:<id>` are
|
|
515
|
+
* images; an empty value clears the field. A local image is uploaded to
|
|
516
|
+
* the asset library first (the caller swaps `file:<path>` for its asset).
|
|
517
|
+
*/
|
|
518
|
+
export function templateValue(raw) {
|
|
519
|
+
if (raw === '')
|
|
520
|
+
return null;
|
|
521
|
+
const [prefix, ...rest] = raw.split(':');
|
|
522
|
+
const id = rest.join(':');
|
|
523
|
+
if (id) {
|
|
524
|
+
switch (prefix) {
|
|
525
|
+
case 'asset':
|
|
526
|
+
return { assetId: id };
|
|
527
|
+
case 'generation': {
|
|
528
|
+
const [generationId, n] = id.split('/');
|
|
529
|
+
const index = n === undefined ? 0 : Number(n) - 1;
|
|
530
|
+
if (!Number.isInteger(index) || index < 0 || index > 7) {
|
|
531
|
+
throw usageError('Write generation:<id>/<n> with n from 1 to 8.');
|
|
532
|
+
}
|
|
533
|
+
return { generationId, index };
|
|
534
|
+
}
|
|
535
|
+
case 'background':
|
|
536
|
+
return { backgroundId: id };
|
|
537
|
+
case 'brand-image':
|
|
538
|
+
return { brandImageId: id };
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return raw;
|
|
542
|
+
}
|
|
543
|
+
/** `--set a=b` pairs; values of local image files are returned apart. */
|
|
544
|
+
export function templateValues(sets) {
|
|
545
|
+
const values = {};
|
|
546
|
+
const files = {};
|
|
547
|
+
for (const set of sets) {
|
|
548
|
+
const eq = set.indexOf('=');
|
|
549
|
+
if (eq < 1) {
|
|
550
|
+
throw usageError(`Write --set field=value (got "${set}").`);
|
|
551
|
+
}
|
|
552
|
+
const field = set.slice(0, eq).trim();
|
|
553
|
+
const raw = set.slice(eq + 1);
|
|
554
|
+
if (IMAGE_FILE.test(raw) && !raw.includes(':'))
|
|
555
|
+
files[field] = raw;
|
|
556
|
+
else
|
|
557
|
+
values[field] = templateValue(raw);
|
|
558
|
+
}
|
|
559
|
+
return { values, files };
|
|
560
|
+
}
|
|
561
|
+
/** Size, format and video options shared by `render` and `html`. */
|
|
562
|
+
export function renderOptions(v) {
|
|
563
|
+
const out = {};
|
|
564
|
+
if (v.size) {
|
|
565
|
+
if (!TEMPLATE_SIZES.includes(v.size)) {
|
|
566
|
+
throw usageError(`--size must be ${TEMPLATE_SIZES.join(', ')}.`);
|
|
567
|
+
}
|
|
568
|
+
out.size = v.size;
|
|
569
|
+
}
|
|
570
|
+
const width = intOption(v.width, 'width', 200, 2048);
|
|
571
|
+
const height = intOption(v.height, 'height', 200, 2048);
|
|
572
|
+
if ((width === undefined) !== (height === undefined)) {
|
|
573
|
+
throw usageError('Give --width and --height together.');
|
|
574
|
+
}
|
|
575
|
+
if (width !== undefined && v.size) {
|
|
576
|
+
throw usageError('Use --size or --width and --height, not both.');
|
|
577
|
+
}
|
|
578
|
+
if (width !== undefined)
|
|
579
|
+
out.width = width;
|
|
580
|
+
if (height !== undefined)
|
|
581
|
+
out.height = height;
|
|
582
|
+
if (v.video) {
|
|
583
|
+
if (v.scale !== undefined)
|
|
584
|
+
throw usageError('--scale is for images.');
|
|
585
|
+
const seconds = intOption(v.seconds, 'seconds', 2, 15);
|
|
586
|
+
if (seconds !== undefined)
|
|
587
|
+
out.seconds = seconds;
|
|
588
|
+
if (v.format !== undefined) {
|
|
589
|
+
const format = v.format.toLowerCase();
|
|
590
|
+
if (format !== 'mp4' && format !== 'mov') {
|
|
591
|
+
throw usageError('--format must be mp4 or mov (mov keeps transparency).');
|
|
592
|
+
}
|
|
593
|
+
out.format = format;
|
|
594
|
+
}
|
|
595
|
+
if (v.matte !== undefined) {
|
|
596
|
+
if (!/^#[0-9a-f]{6}$/i.test(v.matte)) {
|
|
597
|
+
throw usageError('--matte takes a color like #00b140.');
|
|
598
|
+
}
|
|
599
|
+
out.matte = v.matte;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
if (v.seconds !== undefined || v.matte !== undefined) {
|
|
604
|
+
throw usageError('--seconds and --matte go with --video.');
|
|
605
|
+
}
|
|
606
|
+
if (v.scale !== undefined) {
|
|
607
|
+
if (v.scale !== '1' && v.scale !== '2') {
|
|
608
|
+
throw usageError('--scale must be 1 or 2.');
|
|
609
|
+
}
|
|
610
|
+
out.scale = Number(v.scale);
|
|
611
|
+
}
|
|
612
|
+
if (v.format !== undefined) {
|
|
613
|
+
const format = v.format.toLowerCase();
|
|
614
|
+
if (format !== 'png' && format !== 'webp') {
|
|
615
|
+
throw usageError('--format must be png or webp (mp4 or mov with --video).');
|
|
616
|
+
}
|
|
617
|
+
out.format = format;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return out;
|
|
621
|
+
}
|
|
622
|
+
/** `--brand <id|default|none>` on a render: left out uses the default brand. */
|
|
623
|
+
export function renderBrand(value) {
|
|
624
|
+
if (value === undefined || value === 'default')
|
|
625
|
+
return undefined;
|
|
626
|
+
return value === 'none' ? null : value;
|
|
627
|
+
}
|