Record browser workflows as video and convert to high-quality GIFs using agent-browser and ffmpeg. Use when users ask to record workflow, create gif, record demo, browser recording, workflow gif, or screen recording.
Record browser automation workflows as video (.webm) and optionally convert them to high-quality animated GIFs using agent-browser for recording and ffmpeg for conversion.
This skill builds on the agent-browser skill to capture browser interactions as video recordings, then uses ffmpeg's palettegen/paletteuse pipeline to produce optimized GIFs suitable for documentation, PRs, and demos.
Before starting a recording workflow, validate that required tools are installed. Run these checks once at the beginning — do not repeat them per step.
Run via Bash:
agent-browser --version
agent-browseris not installed or not on PATH. Install it with:npm install -g @anthropic-ai/agent-browserThen re-run this workflow.
Skip this check if the user only wants a .webm video file. If GIF conversion is needed, run via Bash:
ffmpeg -version
ffmpegis not installed or not on PATH. Install it with:
- Ubuntu/Debian:
sudo apt install ffmpeg- macOS:
brew install ffmpeg- Windows: Download from https://ffmpeg.org/download.html
Then re-run this workflow.
Before starting a recording, configure the browser viewport and display settings. Users can override any default by specifying their preferred values.
| Setting | Default | Range / Options | agent-browser Command |
|---|---|---|---|
| Viewport width | 1280 | 320–1920 px | agent-browser set viewport <w> <h> |
| Viewport height | 720 | 240–1080 px | agent-browser set viewport <w> <h> |
| Color scheme | light | light / dark | agent-browser set media light or agent-browser set media dark |
| GIF FPS | 12 | 5–30 | Used in ffmpeg conversion (not an agent-browser setting) |
| GIF max width | 800 | 320–1920 px | Used in ffmpeg scaling (not an agent-browser setting) |
Run these commands via Bash before starting the recording:
# Set viewport (default 1280x720, or use user-provided dimensions)
agent-browser set viewport 1280 720
# Set color scheme (default light)
agent-browser set media light
If the user requests different values (e.g., "record at 1920x1080 in dark mode"), substitute their values:
agent-browser set viewport 1920 1080
agent-browser set media dark
GIF FPS and max width are applied later during the ffmpeg conversion step — store the user's requested values (or the defaults of 12 FPS and 800px max width) for use in that step.
Follow this lifecycle to record a browser workflow as a .webm video file.
Apply viewport and display settings before starting the recording (see Configuration above):
agent-browser set viewport 1280 720
agent-browser set media light
Begin video capture by specifying an output path for the .webm file:
agent-browser record start <output-path>.webm
For example: agent-browser record start demo.webm
Perform the workflow steps using agent-browser commands between record start and record stop. Use any agent-browser actions needed — navigate, click, fill, snapshot, etc.
After each navigation, wait for the page to fully load before continuing:
agent-browser open <url>
agent-browser wait --load networkidle
agent-browser click @e2
agent-browser wait --load networkidle
Use agent-browser wait --load networkidle after any action that triggers a page navigation or significant network activity. This ensures the page is fully rendered before the next action, producing a clean recording.
For non-navigation interactions (typing, clicking buttons that update the DOM without navigating), use a short delay if needed:
agent-browser wait 500
Once all workflow steps are complete, stop the recording:
agent-browser record stop
Confirm the recording was saved successfully by checking the output file exists and is non-empty:
ls -la <output-path>.webm
Resolve the output file path before starting the recording workflow.
/home/user/recordings/demo.gif or ./output/demo.webm): Use that path as-is.<cwd>/<name>.gif (final) and <cwd>/<name>.webm (intermediate video).<cwd>/<name>.webm.login-flow.gif, dashboard-demo.webm).When converting to GIF, an intermediate .webm video is recorded first. Store it alongside the final output:
<output-dir>/<name>.gif<output-dir>/<name>.webmThe intermediate .webm is deleted after successful GIF conversion (see the conversion section).
Before starting the recording, check if the output file(s) already exist:
ls <output-path>.gif 2>/dev/null
ls <output-path>.webm 2>/dev/null
# 1. Configure
agent-browser set viewport 1280 720
agent-browser set media light
# 2. Start recording
agent-browser record start workflow-demo.webm
# 3. Perform actions
agent-browser open http://localhost:3000
agent-browser wait --load networkidle
agent-browser click @e5
agent-browser wait 500
agent-browser fill @e8 "Hello World"
agent-browser click @e10
agent-browser wait --load networkidle
# 4. Stop recording
agent-browser record stop
# 5. Verify
ls -la workflow-demo.webm
Convert a recorded .webm video to a high-quality animated GIF using ffmpeg's two-pass palettegen/paletteuse pipeline. This produces significantly better color quality than a single-pass conversion.
Run this two-pass ffmpeg command via Bash, substituting <input>, <output>, <fps>, and <max_width> with actual values:
ffmpeg -i <input>.webm -filter_complex "[0:v] fps=<fps>,scale=<max_width>:-1:flags=lanczos,split [a][b];[a] palettegen=stats_mode=full [p];[b][p] paletteuse=dither=sierra2_4a" -loop 0 <output>.gif
Filter breakdown:
| Filter | Purpose |
|---|---|
fps=<fps> | Set output frame rate (default 12, range 5–30) |
scale=<max_width>:-1:flags=lanczos | Scale width to max_width, preserve aspect ratio, use Lanczos resampling for high-quality downscaling |
split [a][b] | Duplicate the stream for two-pass processing |
palettegen=stats_mode=full | Generate an optimal 256-color palette from all frames |
paletteuse=dither=sierra2_4a | Apply the palette with Sierra dithering for smooth gradients |
-loop 0 | Loop the GIF infinitely |
Use these defaults unless the user specifies otherwise:
If the user requests custom values, substitute them in the command. Clamp values to the valid ranges — if a user requests 60 FPS, use 30; if they request 100px width, use 320.
ffmpeg -i workflow-demo.webm -filter_complex "[0:v] fps=12,scale=800:-1:flags=lanczos,split [a][b];[a] palettegen=stats_mode=full [p];[b][p] paletteuse=dither=sierra2_4a" -loop 0 workflow-demo.gif
User requests 24 FPS at 1280px max width:
ffmpeg -i workflow-demo.webm -filter_complex "[0:v] fps=24,scale=1280:-1:flags=lanczos,split [a][b];[a] palettegen=stats_mode=full [p];[b][p] paletteuse=dither=sierra2_4a" -loop 0 workflow-demo.gif
After the ffmpeg command completes:
Verify the GIF exists and is non-empty:
ls -la <output>.gif
Delete the intermediate .webm file (only after confirming the GIF was created successfully):
rm <input>.webm
Report the result to the user with the output path and file size.
Handle failures at each stage of the workflow with clear, actionable feedback. The goal is to preserve any partial output and help the user resolve the issue.
If agent-browser record start <path>.webm returns a non-zero exit code or outputs an error:
Recording failed to start. Possible causes:
- agent-browser is not running or has no active page — try
agent-browser open <url>first.- The output path is not writable — check directory permissions.
- Another recording may already be in progress — try
agent-browser record stopfirst.
If any agent-browser command (click, fill, navigate, etc.) fails while recording is active:
agent-browser record stop
ls -la <output-path>.webm
Do NOT delete the partial .webm — the user may want to review what was captured.
If the output .webm file exists but is 0 bytes after agent-browser record stop:
The recording completed but captured nothing (0-byte file). This usually means:
- No browser page was open when recording started — ensure
agent-browser open <url>runs beforeagent-browser record start.- The recording started and stopped too quickly — add waits between actions.
- The browser viewport was not visible — check viewport configuration.
If the ffmpeg command returns a non-zero exit code or outputs an error:
GIF conversion failed. The original video has been preserved at
<path>.webm. Possible causes:
- The .webm file may be corrupted — try playing it with
ffplay <path>.webm.- ffmpeg may not support the codec — try re-recording.
- Insufficient disk space — check with
df -h.You can retry conversion manually:
ffmpeg -i <input>.webm -filter_complex "[0:v] fps=12,scale=800:-1:flags=lanczos,split [a][b];[a] palettegen=stats_mode=full [p];[b][p] paletteuse=dither=sierra2_4a" -loop 0 <output>.gif