webreel
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesewebreel
webreel
webreel records scripted browser demos as MP4, GIF, or WebM with cursor animation, keystroke overlays, and sound effects. You define steps in a JSON config, and webreel drives headless Chrome, captures frames, and encodes with ffmpeg.
webreel 可将脚本化的浏览器演示录制为 MP4、GIF 或 WebM 格式,自带光标动画、按键输入叠加层和音效。你可以在 JSON 配置中定义操作步骤,webreel 会驱动 headless Chrome、捕获帧画面并通过 ffmpeg 编码生成视频。
Installation
安装
Install webreel as a project dependency so the version is pinned in the lockfile. This ensures deterministic recordings across machines and CI.
bash
npm install webreelIf the project already has webreel in its dependencies, skip this step.
将 webreel 安装为项目依赖,这样版本会被锁定在 lockfile 中,确保在不同机器和 CI 环境下的录制结果一致。
bash
npm install webreel如果项目依赖中已经包含 webreel,可跳过此步骤。
Quick start
快速开始
bash
undefinedbash
undefinedScaffold a config
生成配置脚手架
npx webreel init --name my-demo --url https://example.com
npx webreel init --name my-demo --url https://example.com
Edit webreel.config.json with your steps
编辑 webreel.config.json 填写你的操作步骤
Preview in a visible browser (no recording)
在可视化浏览器中预览(不录制)
npx webreel preview my-demo
npx webreel preview my-demo
Record the video
录制视频
npx webreel record my-demo
`npx` resolves to the locally installed version when webreel is in `devDependencies`. Output lands in `videos/` by default (configurable via `outDir`).npx webreel record my-demo
当 webreel 位于 `devDependencies` 中时,`npx` 会自动解析为本地安装的版本。输出文件默认存放在 `videos/` 目录下(可通过 `outDir` 配置修改)。CLI commands
CLI 命令
init
init
Scaffold a new .
webreel.config.jsonbash
webreel init
webreel init --name login-flow --url https://myapp.com
webreel init --name hero -o hero.config.jsonFlags: (video name), (starting URL), (output file path).
--name--url-o, --output生成新的 脚手架。
webreel.config.jsonbash
webreel init
webreel init --name login-flow --url https://myapp.com
webreel init --name hero -o hero.config.json参数:(视频名称)、(起始URL)、(输出文件路径)。
--name--url-o, --outputrecord
record
Record one or more videos.
bash
webreel record # all videos in config
webreel record hero login # specific videos by name
webreel record -c custom.config.json # custom config path
webreel record --watch # re-record on config change
webreel record --verbose # log each step
webreel record --dry-run # print resolved config only
webreel record --frames # save raw JPEGs to .webreel/frames/录制单个或多个视频。
bash
webreel record # 录制配置中的所有视频
webreel record hero login # 按名称录制指定视频
webreel record -c custom.config.json # 指定自定义配置文件路径
webreel record --watch # 配置变更时自动重新录制
webreel record --verbose # 打印每个步骤的执行日志
webreel record --dry-run # 仅打印解析完成的配置
webreel record --frames # 将原始JPEG帧保存到 .webreel/frames/ 目录preview
preview
Run steps in a visible browser without recording.
bash
webreel preview
webreel preview hero --verbose在可视化浏览器中运行步骤,不进行录制。
bash
webreel preview
webreel preview hero --verbosecomposite
composite
Re-apply overlays (cursor, HUD, sfx) to existing raw video without re-recording. Useful for tweaking theme settings.
bash
webreel composite
webreel composite hero为已有的原始视频重新应用叠加层(光标、HUD、音效),无需重新录制。适合调整主题配置时使用。
bash
webreel composite
webreel composite herovalidate
validate
Check config for errors without running anything.
bash
webreel validate
webreel validate -c custom.config.json检查配置是否存在错误,不执行任何操作。
bash
webreel validate
webreel validate -c custom.config.jsonConfig structure
配置结构
Config files are auto-discovered as (or , , , ). Use to specify a custom path.
webreel.config.json.ts.mts.js.mjs-c配置文件会自动识别为 (或 、、、)。可使用 参数指定自定义路径。
webreel.config.json.ts.mts.js.mjs-cTop-level fields
顶级配置项
| Field | Default | Description |
|---|---|---|
| - | |
| | Output directory for rendered videos |
| | Base URL prepended to relative video URLs |
| | Default viewport |
| - | Cursor and HUD overlay theme |
| - | Sound effect settings |
| - | Array of step file paths prepended to all videos |
| - | Default delay (ms) appended after each step |
| - | Cursor dwell time (ms) before a click |
| 字段名 | 默认值 | 说明 |
|---|---|---|
| - | |
| | 渲染后视频的输出目录 |
| | 相对视频URL的前缀地址 |
| | 默认视口尺寸 |
| - | 光标和HUD叠加层主题 |
| - | 音效配置 |
| - | 所有视频都会前置引入的步骤文件路径数组 |
| - | 每个步骤执行后追加的默认延迟(毫秒) |
| - | 点击前光标停留的时间(毫秒) |
Per-video fields
单视频配置项
Each entry in the map supports:
videos| Field | Default | Description |
|---|---|---|
| required | URL to open (absolute or relative to |
| inherited | Override viewport |
| - | CSS zoom factor |
| - | Selector or text to wait for before starting steps |
| | Output path ( |
| | Thumbnail config, or |
| inherited | Step files to prepend |
| inherited | Override theme |
| inherited | Override sound effects |
| inherited | Override default delay |
| inherited | Override click dwell |
| | Frame rate |
| | Encoding quality (1-100) |
| required | Array of step objects |
videos| 字段名 | 默认值 | 说明 |
|---|---|---|
| 必填项 | 要打开的URL(绝对路径或相对于 |
| 继承自顶级配置 | 覆盖视口尺寸 |
| - | CSS 缩放比例 |
| - | 开始执行步骤前等待的选择器或文本内容 |
| | 输出路径(支持 |
| | 缩略图配置,或设置为 |
| 继承自顶级配置 | 要前置引入的步骤文件 |
| 继承自顶级配置 | 覆盖主题配置 |
| 继承自顶级配置 | 覆盖音效配置 |
| 继承自顶级配置 | 覆盖默认延迟 |
| 继承自顶级配置 | 覆盖点击停留时间 |
| | 帧率 |
| | 编码质量(1-100) |
| 必填项 | 步骤对象数组 |
Videos map
视频映射
Videos are keyed by name in the config:
json
{
"videos": {
"hero": { "url": "...", "steps": [...] },
"login": { "url": "...", "steps": [...] }
}
}Record specific videos by name: .
webreel record hero login配置中的视频通过名称作为键进行定义:
json
{
"videos": {
"hero": { "url": "...", "steps": [...] },
"login": { "url": "...", "steps": [...] }
}
}可通过名称录制指定视频:。
webreel record hero loginStep types
步骤类型
Each step has an field. Most steps accept optional , (ms after step), and fields.
actionlabeldelaydescription| Action | Key fields | Purpose |
|---|---|---|
| | Wait for a duration |
| | Click an element |
| | Type text into an input |
| | Press a key combo (e.g. |
| | Drag between two elements |
| | Scroll the page or an element |
| | Wait for an element to appear |
| | Move cursor to an element |
| | Navigate to a new URL |
| | Hover over an element |
| | Select a dropdown value |
| | Capture a PNG screenshot |
For full field details on every step type, see steps-reference.md.
每个步骤都包含 字段。大部分步骤支持可选的 、(步骤完成后的延迟毫秒数)和 字段。
actionlabeldelaydescription| Action | 关键字段 | 用途 |
|---|---|---|
| | 等待指定时长 |
| | 点击某个元素 |
| | 在输入框中输入文本 |
| | 按下组合键(例如 |
| | 在两个元素之间拖拽 |
| | 滚动页面或某个元素 |
| | 等待某个元素出现 |
| | 将光标移动到某个元素上 |
| | 跳转到新的URL |
| | 悬停在某个元素上 |
| | 选择下拉框选项 |
| | 捕获PNG格式截图 |
如需查看所有步骤类型的完整字段说明,请参阅 steps-reference.md。
Element targeting
元素定位
Many steps target elements using these fields:
- - match by visible text content
text - - match by CSS selector
selector - - narrow the search to a parent matching this CSS selector
within
You can use or (not both). is optional and scopes the search.
textselectorwithinjson
{ "action": "click", "text": "Submit" }
{ "action": "click", "selector": "#submit-btn" }
{ "action": "click", "text": "Submit", "within": ".modal" }很多步骤通过以下字段定位元素:
- - 按可见文本内容匹配
text - - 按CSS选择器匹配
selector - - 将搜索范围缩小到匹配该CSS选择器的父元素内
within
你可以使用 或 (不可同时使用)。 是可选参数,用于限定搜索范围。
textselectorwithinjson
{ "action": "click", "text": "Submit" }
{ "action": "click", "selector": "#submit-btn" }
{ "action": "click", "text": "Submit", "within": ".modal" }Viewport presets
视口预设
Use preset names as string values for , or specify :
viewport{ width, height }desktopdesktop-hdlaptopmacbook-airmacbook-proipadipad-proipad-miniiphone-15iphone-15-pro-maxiphone-sepixel-8galaxy-s24你可以为 使用预设名称作为字符串值,也可以自定义 :
viewport{ width, height }预设包括: (1920x1080)、 (2560x1440)、 (1366x768)、 (1440x900)、 (1512x982)、 (1024x1366)、 (834x1194)、 (768x1024)、 (393x852)、 (430x932)、 (375x667)、 (412x915)、 (360x780)。
desktopdesktop-hdlaptopmacbook-airmacbook-proipadipad-proipad-miniiphone-15iphone-15-pro-maxiphone-sepixel-8galaxy-s24Theme
主题配置
Customize cursor appearance and keystroke HUD:
json
{
"theme": {
"cursor": {
"image": "./cursor.svg",
"size": 32,
"hotspot": "center"
},
"hud": {
"background": "rgba(30, 41, 59, 0.85)",
"color": "#e2e8f0",
"fontSize": 48,
"fontFamily": "\"SF Mono\", monospace",
"borderRadius": 12,
"position": "top"
}
}
}- - path to a custom cursor SVG or PNG
cursor.image - - cursor size in pixels
cursor.size - -
cursor.hotspot(default) or"top-left""center" - -
hud.positionor"top""bottom"
你可以自定义光标外观和按键HUD样式:
json
{
"theme": {
"cursor": {
"image": "./cursor.svg",
"size": 32,
"hotspot": "center"
},
"hud": {
"background": "rgba(30, 41, 59, 0.85)",
"color": "#e2e8f0",
"fontSize": 48,
"fontFamily": "\"SF Mono\", monospace",
"borderRadius": 12,
"position": "top"
}
}
}- - 自定义光标SVG或PNG的路径
cursor.image - - 光标尺寸(单位:像素)
cursor.size - - 光标热点位置,可选
cursor.hotspot(默认)或"top-left""center" - - HUD位置,可选
hud.position或"top""bottom"
Common patterns
常见使用模式
Shared steps via include
通过include共享步骤
Factor out reusable step sequences (e.g. dismissing a cookie banner) into JSON files:
json
// steps/dismiss-banner.json
{
"steps": [
{ "action": "wait", "selector": ".cookie-banner", "timeout": 5000 },
{ "action": "click", "selector": ".accept-btn", "delay": 300 }
]
}Reference them in the config:
json
{
"include": ["./steps/dismiss-banner.json"],
"videos": { ... }
}将可复用的步骤序列(例如关闭Cookie弹窗)提取为独立JSON文件:
json
// steps/dismiss-banner.json
{
"steps": [
{ "action": "wait", "selector": ".cookie-banner", "timeout": 5000 },
{ "action": "click", "selector": ".accept-btn", "delay": 300 }
]
}在配置中引用即可:
json
{
"include": ["./steps/dismiss-banner.json"],
"videos": { ... }
}Multiple videos in one config
单配置多视频
Define several videos in the map. Shared settings (, , ) are inherited from the top level.
videosviewportthemedefaultDelay在 映射中定义多个视频,共享的配置(、、)会从顶级配置继承。
videosviewportthemedefaultDelayEnvironment variables
环境变量
Config values support and substitution from the environment.
$VAR${VAR}配置值支持从环境变量读取 和 格式的变量。
$VAR${VAR}Output formats
输出格式
Set the extension to control format: (default), , .
output.mp4.gif.webmjson
{ "output": "demo.gif" }通过设置 的扩展名控制输出格式:(默认)、、。
output.mp4.gif.webmjson
{ "output": "demo.gif" }Tips
使用提示
- Always set on a video to ensure the page is ready before steps run.
waitFor - Use on individual steps to control pacing between actions.
delay - Use during development for automatic re-recording on config changes.
--watch - Use to iterate on theme/overlay settings without re-recording.
composite - Use to debug step execution.
--verbose - Use to inspect the fully resolved config (includes, env vars, defaults).
--dry-run - Use to scale up small UIs for readability in the recording.
zoom - Start with to verify steps work before committing to a full recording.
preview
- 始终为视频设置 配置,确保步骤执行前页面已加载完成。
waitFor - 为单个步骤设置 控制操作之间的节奏。
delay - 开发过程中使用 参数,配置变更时自动重新录制。
--watch - 使用 命令调整主题/叠加层配置,无需重新录制。
composite - 使用 参数调试步骤执行过程。
--verbose - 使用 参数查看完全解析后的配置(包括引入文件、环境变量、默认值)。
--dry-run - 使用 缩放较小的UI,提升录制内容的可读性。
zoom - 正式录制前先使用 验证步骤运行正常。
preview
Reference files
参考文件
- steps-reference.md - detailed docs for all 12 step types
- examples.md - annotated config examples for common use cases
- steps-reference.md - 所有12种步骤类型的详细文档
- examples.md - 常见使用场景的带注释配置示例