Skip to content

The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.

CLI: no capture command; an agent takes the picture with its own tools (#83)

riverisbuilding5c2000b8cd04
diff --git a/.changeset/no-capture-command.md b/.changeset/no-capture-command.md
new file mode 100644
index 0000000..aeb5b24
--- /dev/null
+++ b/.changeset/no-capture-command.md
@@ -0,0 +1,5 @@
+---
+'openfilm': patch
+---
+
+`openfilm capture` is gone: an agent takes a picture of a live web page with its own tools, so OpenFilm's core leaves it out. The keynote and screen-demo skills no longer point to it.
diff --git a/README.md b/README.md
index d43f81c..187ffa2 100644
--- a/README.md
+++ b/README.md
@@ -66,7 +66,6 @@ openfilm open [folder | url] # show a film in Studio: a new one, an existin
openfilm look [what] [t | a-b] # check the film, a page or a media file: a contact sheet, one frame, or a range
openfilm render [a-b] # the MP4; --4k, --blur (motion blur), --alpha (.webm / .mov)
openfilm get [what] # voice-over, music, sound effects, transcripts, images, video, from your services
-openfilm capture <url> <file.png> # a picture of a live web page (a product, a site), sharp enough to fill the stage
```
`openfilm <command> --help` lists a command's options; `openfilm get` alone lists what can be made and how to
diff --git a/README.zh-CN.md b/README.zh-CN.md
index d3c90db..3278816 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -65,7 +65,6 @@ openfilm open [folder | url] # 在 Studio 里打开片子:新建、打开
openfilm look [what] [t | a-b] # 检查片子、某个页面或媒体文件:缩略图总览、单帧或一段区间
openfilm render [a-b] # 渲染成 MP4;--4k、--blur(运动模糊)、--alpha(.webm / .mov)
openfilm get [what] # 用你接入的服务生成配音、音乐、音效、字幕转写、图片和视频
-openfilm capture <url> <file.png> # 截取正在运行的网页(产品、网站),清晰到能占满画面
```
`openfilm <命令> --help` 列出某个命令的选项;单独运行 `openfilm get` 会列出能生成什么,以及怎么在 Studio 里用你
diff --git a/packages/openfilm/README.md b/packages/openfilm/README.md
index 9f4e3a3..a0d6d4a 100644
--- a/packages/openfilm/README.md
+++ b/packages/openfilm/README.md
@@ -26,7 +26,6 @@ openfilm open [folder | url] # show a film in Studio (a GitHub address fetc
openfilm look [what] [t | a-b] # check the film, a page or a media file
openfilm render [a-b] # the MP4; --4k, --blur, --alpha
openfilm get [what] # voice-over, music, sound effects, transcripts, images, video, from your services
-openfilm capture <url> <file.png> # a picture of a live web page, to show a product as it is
```
`MANUAL.md` (in this package) is what `openfilm` tells your agent, and `SPEC.md` is the film format, for anyone
diff --git a/packages/openfilm/bin/openfilm.mjs b/packages/openfilm/bin/openfilm.mjs
index 200862b..48c5807 100755
--- a/packages/openfilm/bin/openfilm.mjs
+++ b/packages/openfilm/bin/openfilm.mjs
@@ -7,7 +7,6 @@ const USAGE = `openfilm — a film is a function of time: given t, it draws that
openfilm look [what] [t | a-b] check the film and draw it: a contact sheet with its sound and loudness
openfilm render [a-b] the MP4, saved beside film.html
openfilm get [what] [--options] voice-over, music, sound effects, transcripts, images, video, from a connected service
- openfilm capture <url> <file.png> a picture of a live web page, to show a product or a site as it is
openfilm skills the skills this film can be made with; \`openfilm skill <name>\` prints one
openfilm update the newest OpenFilm; Studio starts again on it
@@ -75,19 +74,6 @@ openfilm skill remove <name>
--4k 3840 px wide --scale <n> any device pixel ratio
--blur motion blur (8 samples) --samples <n> --shutter <0..1>
--alpha transparent background --workers <n> parallel browsers`,
- capture: `openfilm capture <url> <file.png>
-
- A picture of a live web page (a product, a site) as it is, sharp enough to fill the stage, taken in the browser
- OpenFilm draws films in: nothing to install. Prints the picture's path and its size in pixels.
-
- --size <w>x<h> the window, in px (1440x900; a phone: 390x844)
- --scale <n> pixels per px (2)
- --full the whole page, top to bottom, for a scroll in the film
- --selector <css> only this element (a panel, a card)
- --click <css> click it first (a tab, a menu); give it again for more, in order
- --hide <css> remove it first (a cookie banner, a chat bubble); give it again for more
- --dark the page in its dark theme
- --wait <ms> time for the page to settle before the picture (1500)`,
};
/* `openfilm` alone: the manual, the whole of what an agent needs to know. `get` takes any options its verb has,
@@ -135,8 +121,6 @@ try {
count: { type: 'string' }, out: { type: 'string', short: 'o' }, '4k': { type: 'boolean' }, scale: { type: 'string' },
blur: { type: 'boolean' }, samples: { type: 'string' }, shutter: { type: 'string' }, alpha: { type: 'boolean' },
fps: { type: 'string' }, workers: { type: 'string' }, help: { type: 'boolean', short: 'h' },
- size: { type: 'string' }, full: { type: 'boolean' }, wait: { type: 'string' }, dark: { type: 'boolean' },
- click: { type: 'string', multiple: true }, hide: { type: 'string', multiple: true }, selector: { type: 'string' },
},
});
} catch (e) {
@@ -163,7 +147,6 @@ const commands = {
open: () => open(args[0] ?? null),
look: () => import('../src/look.mjs').then((m) => m.look(args, opts)),
render: () => import('../src/render.mjs').then((m) => m.render(args, opts)),
- capture: () => import('../src/capture.mjs').then((m) => m.capture(args, opts)),
update: () => import('../studio/client.mjs').then((m) => m.updateOpenfilm((line) => console.error(line))),
skills: () => import('../src/skills-cli.mjs').then((m) => m.skillsCommand(RUN)),
skill: () => import('../src/skills-cli.mjs').then((m) => m.skillCommand(args, RUN)),
diff --git a/packages/openfilm/skills/SOURCE b/packages/openfilm/skills/SOURCE
index 8b79ec7..ebcc4ce 100644
--- a/packages/openfilm/skills/SOURCE
+++ b/packages/openfilm/skills/SOURCE
@@ -1,2 +1,2 @@
-https://github.com/openfilm/skills/commit/702f16944c14d64a87fc5149cb865bd5c95c895f
+https://github.com/openfilm/skills/commit/1111136608bfd7fda174ba0fe7c5b6f87138f8c7
Copied by `pnpm skills:sync`. Change the skills in https://github.com/openfilm/skills, not here.
diff --git a/packages/openfilm/skills/keynote/SKILL.md b/packages/openfilm/skills/keynote/SKILL.md
index a45dee3..d694767 100644
--- a/packages/openfilm/skills/keynote/SKILL.md
+++ b/packages/openfilm/skills/keynote/SKILL.md
@@ -21,7 +21,6 @@ proof, so the viewer leaves knowing what it is and wanting it. Surprise us; the
## What you have
-OpenFilm's own headless browser captures the live product with nothing to install: `npx openfilm capture --help`.
Anything you can make pictures and motion with: the web platform and any library on it, Blender or any renderer whose
output becomes a clip, any font whose license allows it, music and sound from `npx openfilm get`, your own built-in
tools, and services the person has keys for. OpenFilm's own rules still hold: the picture at t depends on t alone, a
diff --git a/packages/openfilm/skills/keynote/openfilm.json b/packages/openfilm/skills/keynote/openfilm.json
index b278385..1850dd5 100644
--- a/packages/openfilm/skills/keynote/openfilm.json
+++ b/packages/openfilm/skills/keynote/openfilm.json
@@ -1,5 +1,5 @@
{
- "version": "0.1.0",
+ "version": "0.1.1",
"repository": "https://github.com/openfilm/skills/tree/main/skills/keynote",
"kind": "style",
"order": 9,
diff --git a/packages/openfilm/skills/screen-demo/SKILL.md b/packages/openfilm/skills/screen-demo/SKILL.md
index c00d35c..6fdf7a5 100644
--- a/packages/openfilm/skills/screen-demo/SKILL.md
+++ b/packages/openfilm/skills/screen-demo/SKILL.md
@@ -24,10 +24,9 @@ sees each step land, never waits, and could do the same in the product today.
## What you have
The recording, cut by its in and out points and sped up with `speed`, never re-encoded; a page can also play it,
-silent, with its time set from t, so the picture can move over it. OpenFilm's own headless browser captures the live
-product with nothing to install: `npx openfilm capture --help`. A voice from `npx openfilm get tts`,
-music and sound from `get`, your own built-in tools, services the person has keys for, and anything you can make
-pictures and motion with.
+silent, with its time set from t, so the picture can move over it. A voice from `npx openfilm get tts`, music and
+sound from `get`, your own built-in tools, services the person has keys for, and anything you can make pictures and
+motion with.
## With the person
diff --git a/packages/openfilm/skills/screen-demo/openfilm.json b/packages/openfilm/skills/screen-demo/openfilm.json
index 55ae40b..c2315f0 100644
--- a/packages/openfilm/skills/screen-demo/openfilm.json
+++ b/packages/openfilm/skills/screen-demo/openfilm.json
@@ -1,5 +1,5 @@
{
- "version": "0.1.0",
+ "version": "0.1.1",
"repository": "https://github.com/openfilm/skills/tree/main/skills/screen-demo",
"kind": "workflow",
"order": 3,
diff --git a/packages/openfilm/src/capture.mjs b/packages/openfilm/src/capture.mjs
deleted file mode 100644
index 6ff4885..0000000
--- a/packages/openfilm/src/capture.mjs
+++ /dev/null
@@ -1,51 +0,0 @@
-// openfilm capture: a picture of a live web page (a product, a site), sharp enough to fill a stage, taken in the browser
-// OpenFilm draws films in, so a film can show the real thing instead of a drawing of it.
-import { mkdirSync } from 'node:fs';
-import { dirname, resolve } from 'node:path';
-import { launch } from './host.mjs';
-import { shown, UsageError } from './shared.mjs';
-
-/** The window when none is asked: a laptop's. */
-const SIZE = '1440x900';
-
-/**
- * One picture: the page loads and settles (its network idle, or 10 s at most), loses the elements asked hidden, gets
- * the clicks asked, in order, waits, and is taken: the window, the whole page (`full`) or one element (`selector`).
- * @param {string[]} args the address and the PNG to write
- * @param {{ size?: string, scale?: number, full?: boolean, wait?: string, dark?: boolean, click?: string[],
- * hide?: string[], selector?: string, launch?: Parameters<typeof launch>[0] }} [opts]
- */
-export async function capture(args, opts = {}) {
- const [url, out, ...more] = args;
- if (!url || !out || more.length) throw new UsageError('give the address and the picture to write: capture <url> <file.png>');
- if (!/^(https?|file):\/\//i.test(url)) throw new UsageError(`${url} is not a web address: give it whole, with https://`);
- if (!/\.png$/i.test(out)) throw new UsageError(`${out}: the picture is a .png`);
- const size = /^(\d{2,5})x(\d{2,5})$/.exec(opts.size ?? SIZE);
- if (!size) throw new UsageError(`--size is width x height in px, such as ${SIZE}, not ${opts.size}`);
- const wait = opts.wait === undefined ? 1500 : Number(opts.wait);
- if (!Number.isInteger(wait) || wait < 0 || wait > 60_000) throw new UsageError(`--wait is milliseconds from 0 to 60000, not ${opts.wait}`);
- const file = resolve(out);
- const browser = await launch(opts.launch);
- try {
- const page = await browser.newPage({
- viewport: { width: Number(size[1]), height: Number(size[2]) },
- deviceScaleFactor: opts.scale ?? 2,
- colorScheme: opts.dark ? 'dark' : 'light',
- });
- await page.goto(url, { waitUntil: 'load', timeout: 60_000 });
- /* a page that keeps a connection open never goes idle: wait a while, not forever */
- await page.waitForLoadState('networkidle', { timeout: 10_000 }).catch(() => {});
- /* a banner that is not there has nothing to hide; a click that cannot happen is an error: the view would be wrong */
- for (const sel of opts.hide ?? []) await page.locator(sel).evaluateAll((els) => els.forEach((el) => el.remove())).catch(() => {});
- for (const sel of opts.click ?? []) { await page.locator(sel).first().click({ timeout: 10_000 }); await page.waitForTimeout(600); }
- await page.waitForTimeout(wait);
- mkdirSync(dirname(file), { recursive: true });
- const png = opts.selector
- ? await page.locator(opts.selector).first().screenshot({ path: file, timeout: 10_000 })
- : await page.screenshot({ path: file, fullPage: Boolean(opts.full) });
- /* a PNG's width and height are the first two numbers of its header */
- return { ok: true, lines: [`${shown(file)} ${png.readUInt32BE(16)} × ${png.readUInt32BE(20)} px`] };
- } finally {
- await browser.close();
- }
-}
diff --git a/packages/openfilm/src/capture.test.mjs b/packages/openfilm/src/capture.test.mjs
deleted file mode 100644
index 974e7ed..0000000
--- a/packages/openfilm/src/capture.test.mjs
+++ /dev/null
@@ -1,46 +0,0 @@
-import { test } from 'node:test';
-import assert from 'node:assert/strict';
-import { spawnSync } from 'node:child_process';
-import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
-import { tmpdir } from 'node:os';
-import { join } from 'node:path';
-import { fileURLToPath, pathToFileURL } from 'node:url';
-import { capture } from './capture.mjs';
-import { UsageError } from './shared.mjs';
-
-const BIN = fileURLToPath(new URL('../bin/openfilm.mjs', import.meta.url));
-
-test('a capture asked wrong is a usage error, said before any browser starts', async () => {
- await assert.rejects(capture(['https://example.com']), UsageError);
- await assert.rejects(capture(['example.com', 'a.png']), /not a web address/);
- await assert.rejects(capture(['https://example.com', 'a.jpg']), /is a \.png/);
- await assert.rejects(capture(['https://example.com', 'a.png'], { size: 'big' }), /--size/);
- await assert.rejects(capture(['https://example.com', 'a.png'], { wait: '-1' }), /--wait/);
-});
-
-test('the window at its scale, the whole page, one element, and a banner removed that is not there', { timeout: 60_000 }, async () => {
- const dir = mkdtempSync(join(tmpdir(), 'openfilm-capture-'));
- try {
- writeFileSync(join(dir, 'page.html'), '<!doctype html><body style="margin:0;height:1000px;background:#fff">'
- + '<div id="card" style="position:absolute;left:50px;top:40px;width:300px;height:200px;background:#e33"></div></body>');
- const url = pathToFileURL(join(dir, 'page.html')).href;
- const fast = { size: '400x300', wait: '0' };
- const window = await capture([url, join(dir, 'out', 'window.png')], { ...fast, scale: 1 });
- assert.match(window.lines[0], /400 × 300 px$/);
- assert.ok(existsSync(join(dir, 'out', 'window.png')), 'the folder for the picture is made');
- assert.match((await capture([url, join(dir, 'whole.png')], { ...fast, scale: 1, full: true })).lines[0], /400 × 1000 px$/);
- assert.match((await capture([url, join(dir, 'card.png')], { ...fast, selector: '#card' })).lines[0], /600 × 400 px$/);
- assert.match((await capture([url, join(dir, 'clean.png')], { ...fast, scale: 1, hide: ['#cookie-banner'] })).lines[0], /400 × 300 px$/);
- } finally {
- rmSync(dir, { recursive: true, force: true });
- }
-});
-
-test('openfilm capture is a command: its help, and a wrong address exits 2', () => {
- const help = spawnSync(process.execPath, [BIN, 'capture', '--help'], { encoding: 'utf8' });
- assert.equal(help.status, 0);
- assert.match(help.stdout, /--selector <css>/);
- const wrong = spawnSync(process.execPath, [BIN, 'capture', 'example.com', 'a.png'], { encoding: 'utf8' });
- assert.equal(wrong.status, 2);
- assert.match(wrong.stderr, /not a web address/);
-});