@makemidas/cli 0.11.0 → 0.12.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 +5 -2
- package/dist/args.js +10 -0
- package/dist/captions.js +23 -19
- package/dist/cli.js +3 -1
- package/dist/config.js +1 -1
- package/dist/words.js +21 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ makemidas film new "a 15-second social video for our mugs" --style social --max-
|
|
|
61
61
|
| `models [image\|video\|audio\|transcription\|edit] [--for <use>]` | Model ids, options and credit prices; `--for draft\|final\|edit\|text\|references\|first-last\|sound` lists the image and video models good for that job |
|
|
62
62
|
| `models <id>` | One model: options, defaults, voices, prices and an example request |
|
|
63
63
|
| `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 |
|
|
64
|
-
| `captions <video> --transcript <t.json> [--max-words n] [--no-render]` | Word-by-word captions burned into a video on your computer (HyperFrames and FFmpeg), the spoken word lit; free ([below](#captions-and-cuts-on-your-computer)) |
|
|
64
|
+
| `captions <video> --transcript <t.json> [--max-words n] [--position auto\|bottom\|middle\|top] [--no-render]` | Word-by-word captions burned into a video on your computer (HyperFrames and FFmpeg), the spoken word lit; free ([below](#captions-and-cuts-on-your-computer)) |
|
|
65
65
|
| `cut <video\|audio> --transcript <t.json> --list \| --remove 3,12-18 \| --fillers \| --gaps <s>` | Cut a recording on its words with FFmpeg and write the cut's transcript; free |
|
|
66
66
|
| `frames <video\|url> [--count 1-16] [--width 120-1920]` | Stills evenly spread over a clip and one contact sheet (`<name>-frames/sheet.jpg`), made on your computer with FFmpeg; free, nothing is sent |
|
|
67
67
|
| `feedback "<message>" [--kind bug\|quality\|feature\|praise\|other] [--generation <id>]` | Send feedback to the MakeMidas team (`quality`: a result clearly short of the request) |
|
|
@@ -145,7 +145,10 @@ makemidas captions talk-cut.mp4 --transcript talk-cut.json
|
|
|
145
145
|
- `captions` makes `<name>-captions/`, a HyperFrames project of the captions
|
|
146
146
|
layer, renders it and lays it over the video into `<name>-captions.mp4`; the
|
|
147
147
|
picture and sound are otherwise untouched. A few words show at a time and
|
|
148
|
-
the spoken one lights up gold; `--max-words` sets how many.
|
|
148
|
+
the spoken one lights up gold; `--max-words` sets how many. `--position`
|
|
149
|
+
places them: `auto` (default: on tall video clear of the buttons TikTok,
|
|
150
|
+
Reels and Shorts draw, on wide video near the bottom), `bottom`, `middle`
|
|
151
|
+
or `top`, for when they cover the product or a face. Edit the look in
|
|
149
152
|
the project's `index.html` and run `npm run render` there to make it again.
|
|
150
153
|
Needs Node.js 22+ and FFmpeg; the first render downloads a headless Chrome,
|
|
151
154
|
and rendering takes a few seconds per second of video.
|
package/dist/args.js
CHANGED
|
@@ -87,6 +87,7 @@ export function parse(argv) {
|
|
|
87
87
|
fillers: { type: 'boolean', default: false },
|
|
88
88
|
gaps: { type: 'string' },
|
|
89
89
|
'max-words': { type: 'string' },
|
|
90
|
+
position: { type: 'string' },
|
|
90
91
|
'no-render': { type: 'boolean', default: false },
|
|
91
92
|
subtitles: { type: 'string' },
|
|
92
93
|
'title-card': { type: 'string' },
|
|
@@ -288,6 +289,15 @@ export function sourceArg(rest, command, what) {
|
|
|
288
289
|
}
|
|
289
290
|
return rest[0];
|
|
290
291
|
}
|
|
292
|
+
/** `--position` for captions: auto (default), bottom, middle or top. */
|
|
293
|
+
export function captionPosition(value) {
|
|
294
|
+
if (value === undefined)
|
|
295
|
+
return 'auto';
|
|
296
|
+
if (value === 'auto' || value === 'bottom' || value === 'middle' || value === 'top') {
|
|
297
|
+
return value;
|
|
298
|
+
}
|
|
299
|
+
throw usageError('--position must be auto, bottom, middle or top.');
|
|
300
|
+
}
|
|
291
301
|
/** `--transcript` for captions and cut: the JSON transcribe saves. */
|
|
292
302
|
export function transcriptArg(value, command) {
|
|
293
303
|
if (!value) {
|
package/dist/captions.js
CHANGED
|
@@ -32,29 +32,33 @@ export function captionFit(width, height, maxWords) {
|
|
|
32
32
|
const tall = width < height;
|
|
33
33
|
return { maxWords: maxWords ?? (tall ? 3 : 5), maxEms: tall ? 8 : 14 };
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
35
|
+
export const CAPTION_POSITIONS = ['auto', 'bottom', 'middle', 'top'];
|
|
36
|
+
/**
|
|
37
|
+
* Where captions sit. `auto`: on a tall video, clear of the buttons TikTok,
|
|
38
|
+
* Reels and Shorts draw (30% up); on a wide one, near the bottom. `bottom`
|
|
39
|
+
* hugs the bottom edge, `middle` centres them, `top` puts them near the
|
|
40
|
+
* top: for when `auto` covers what the video shows.
|
|
41
|
+
*/
|
|
42
|
+
export function captionBox(width, height, position = 'auto') {
|
|
43
|
+
const tall = width < height;
|
|
45
44
|
const square = width === height;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
const size = Math.round(tall ? width * 0.08 : Math.min(width, height) * (square ? 0.07 : 0.06));
|
|
46
|
+
const left = Math.round(width * (tall ? 0.111 : 0.08));
|
|
47
|
+
const boxWidth = Math.round(width * (tall ? 0.778 : 0.84));
|
|
48
|
+
const at = (edge, share) => `${edge}: ${Math.round(height * share)}px; align-items: ${edge === 'top' ? 'flex-start' : 'flex-end'};`;
|
|
49
|
+
const place = {
|
|
50
|
+
auto: at('bottom', tall ? 0.3 : square ? 0.14 : 0.09),
|
|
51
|
+
bottom: at('bottom', tall ? 0.12 : 0.06),
|
|
52
|
+
middle: 'top: 0; bottom: 0; align-items: center;',
|
|
53
|
+
top: at('top', tall ? 0.14 : 0.08),
|
|
51
54
|
};
|
|
55
|
+
return { left, width: boxWidth, size, place: place[position] };
|
|
52
56
|
}
|
|
53
57
|
/** The captions page: transparent, one block per caption group. Pure. */
|
|
54
|
-
export function captionsHtml(groups, size, seconds) {
|
|
58
|
+
export function captionsHtml(groups, size, seconds, position = 'auto') {
|
|
55
59
|
const { width: W, height: H } = size;
|
|
56
60
|
const total = r(seconds);
|
|
57
|
-
const box = captionBox(W, H);
|
|
61
|
+
const box = captionBox(W, H, position);
|
|
58
62
|
const blocks = [];
|
|
59
63
|
const tweens = [];
|
|
60
64
|
groups.forEach((group, g) => {
|
|
@@ -91,7 +95,7 @@ export function captionsHtml(groups, size, seconds) {
|
|
|
91
95
|
html, body { width: ${W}px; height: ${H}px; overflow: hidden; background: transparent; }
|
|
92
96
|
#root { position: relative; width: ${W}px; height: ${H}px; }
|
|
93
97
|
/* Captions: edit the size, colours and place here, then npm run render. */
|
|
94
|
-
.cap { position: absolute; left: ${box.left}px; width: ${box.width}px;
|
|
98
|
+
.cap { position: absolute; left: ${box.left}px; width: ${box.width}px; ${box.place} display: flex; justify-content: center; }
|
|
95
99
|
.cap-in { text-align: center; font-family: 'Inter', sans-serif; font-weight: 900; font-size: ${box.size}px; line-height: 1.12; 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); }
|
|
96
100
|
.w { display: inline-block; transform-origin: 50% 70%; margin: 0 0.1em; }
|
|
97
101
|
.w.cjk { margin: 0 0.02em; }
|
|
@@ -169,7 +173,7 @@ export async function captions(g, source, opts) {
|
|
|
169
173
|
const renderLayer = `${hf} render --format mov --fps ${media.video.fps} -o renders/captions.mov`;
|
|
170
174
|
const burn = `ffmpeg -v error -y ${overlayArgs(input, 'renders/captions.mov', media.video, output, media.audio).map(sh).join(' ')}`;
|
|
171
175
|
const files = {
|
|
172
|
-
'index.html': captionsHtml(groups, size, media.seconds),
|
|
176
|
+
'index.html': captionsHtml(groups, size, media.seconds, opts.position),
|
|
173
177
|
'words.json': `${JSON.stringify({ estimated: t.estimated, groups }, null, 2)}\n`,
|
|
174
178
|
'package.json': `${JSON.stringify({
|
|
175
179
|
name: `${name}-captions`,
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Api, KINDS, MODEL_USES, } from "./api.js";
|
|
3
|
-
import { audioInput, compareModels, compareOptions, editInput, filmSeconds, filmSettings, feedbackKind, generationInput, intOption, numberOption, parse, renderBrand, renderOptions, sourceArg, templateValues, transcriptArg, transcriptionInput, usageError, } from "./args.js";
|
|
3
|
+
import { audioInput, captionPosition, compareModels, compareOptions, editInput, filmSeconds, filmSettings, feedbackKind, generationInput, intOption, numberOption, parse, renderBrand, renderOptions, sourceArg, templateValues, transcriptArg, transcriptionInput, usageError, } from "./args.js";
|
|
4
4
|
import * as commands from "./commands.js";
|
|
5
5
|
import { captions } from "./captions.js";
|
|
6
6
|
import { cut } from "./cut.js";
|
|
@@ -66,6 +66,7 @@ Usage:
|
|
|
66
66
|
makemidas captions <video> --transcript <t.json>
|
|
67
67
|
Burn word-by-word captions in, made here with
|
|
68
68
|
HyperFrames and FFmpeg; free (--max-words,
|
|
69
|
+
--position auto|bottom|middle|top,
|
|
69
70
|
--no-render keeps the project only)
|
|
70
71
|
makemidas cut <video|audio> --transcript <t.json>
|
|
71
72
|
Cut on words, here with FFmpeg; free:
|
|
@@ -380,6 +381,7 @@ async function main(argv) {
|
|
|
380
381
|
return captions(g, sourceArg(rest, 'captions', 'video file'), {
|
|
381
382
|
transcript: transcriptArg(v.transcript, 'captions'),
|
|
382
383
|
maxWords: intOption(v['max-words'], 'max-words', 1, 8),
|
|
384
|
+
position: captionPosition(v.position),
|
|
383
385
|
render: !v['no-render'],
|
|
384
386
|
out: v.out,
|
|
385
387
|
force: v.force,
|
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.12.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) {
|
package/dist/words.js
CHANGED
|
@@ -84,15 +84,34 @@ export function estimateWords(text, start, end) {
|
|
|
84
84
|
return { text: word, start: round(from), end: round(at) };
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
+
/** The shortest a word is taken to last. */
|
|
88
|
+
export const MIN_WORD = 0.15;
|
|
89
|
+
/**
|
|
90
|
+
* Speech models sometimes time a word far too short (a 0.03 s "kept" after
|
|
91
|
+
* a pause): its sound began earlier. Such a word starts earlier, into the
|
|
92
|
+
* silence before it but never into the word before, so its caption lights
|
|
93
|
+
* long enough to see and a cut before it doesn't clip it.
|
|
94
|
+
*/
|
|
95
|
+
export function widenShortWords(words) {
|
|
96
|
+
return words.map((word, i) => {
|
|
97
|
+
const short = MIN_WORD - (word.end - word.start);
|
|
98
|
+
if (short <= 0)
|
|
99
|
+
return word;
|
|
100
|
+
const room = word.start - (words[i - 1]?.end ?? 0);
|
|
101
|
+
if (room <= 0)
|
|
102
|
+
return word;
|
|
103
|
+
return { ...word, start: round(word.start - Math.min(room, short)) };
|
|
104
|
+
});
|
|
105
|
+
}
|
|
87
106
|
/** Every word with its time: the transcript's own, or estimated. */
|
|
88
107
|
export function timedWords(t) {
|
|
89
108
|
const last = t.segments.at(-1)?.end ?? 0;
|
|
90
109
|
const duration = Math.max(t.durationSeconds || 0, last);
|
|
91
110
|
if (t.words?.length) {
|
|
92
111
|
return {
|
|
93
|
-
words: t.words
|
|
112
|
+
words: widenShortWords(t.words
|
|
94
113
|
.map((w) => ({ text: w.word.trim(), start: w.start, end: w.end }))
|
|
95
|
-
.filter((w) => w.text && w.end >= w.start),
|
|
114
|
+
.filter((w) => w.text && w.end >= w.start)),
|
|
96
115
|
estimated: false,
|
|
97
116
|
duration,
|
|
98
117
|
language: t.language,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makemidas/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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",
|