record fails with "ffmpeg write failed: Broken pipe" on ffmpeg < 5.1 (-fps_mode unsupported)

Author: jakvbsCreated Sep 28, 2026Updated Sep 28, 2026

Summary

Since v0.38.0 (PR #1806, "Improve recording video pipeline"), record passes -fps_mode vfr to ffmpeg. -fps_mode only exists in ffmpeg >= 5.1, so on older ffmpeg (e.g. 4.4.2, the default on Ubuntu 22.04) ffmpeg exits during argument parsing and every recording fails. The error surfaced to the user is only an EPIPE, and agent-browser doctor reports the recording setup as healthy.

Environment

  • agent-browser 0.38.1 (npm global, linux-x64 binary)
  • ffmpeg 4.4.2-0ubuntu0.22.04.1 (/usr/bin/ffmpeg), libx264 and libvpx available
  • Ubuntu 22.04 on WSL2

Reproduction

bash
agent-browser --session rectest open https://example.com
agent-browser --session rectest record start /tmp/rectest.webm
sleep 3
agent-browser --session rectest record stop

Output:

✓ Recording started: /tmp/rectest.webm (30 fps)
✗ ffmpeg write failed: Broken pipe (os error 32)

No output file is created. Same result for .mp4 with --fps 15 --cursor.

agent-browser doctor:

pass  ffmpeg version 4.4.2 at /usr/bin/ffmpeg
pass  libvpx (.webm) and libx264 (.mp4) encoders available

Root cause

Captured ffmpeg argv (via a logging wrapper on PATH):

-y -hide_banner -loglevel error -fpsprobesize 0 -probesize 32 -analyzeduration 0 -f image2pipe -c:v png -framerate 30 -i pipe:0 -vf pad=ceil(iw/2)*2:ceil(ih/2)*2 -fps_mode vfr -c:v libvpx -crf 18 -b:v 8000k -deadline realtime -cpu-used 4 -pix_fmt yuv420p -threads 1 /tmp/rectest.webm

ffmpeg 4.4.2 stderr, exit code 1:

Unrecognized option 'fps_mode'.
Error splitting the argument list: Option not found

Minimal check: ffmpeg -hide_banner -f lavfi -i testsrc=d=0.2 -fps_mode vfr -f null -.

v0.37.1 does not pass -fps_mode and records fine with the same ffmpeg. Replacing -fps_mode vfr with -vsync vfr (the pre-5.1 equivalent) makes both .webm and .mp4 --cursor recordings succeed on 4.4.2. Installing a static ffmpeg 7.0.2 also fixes it.

Suggested fix

  1. Detect the ffmpeg version (or probe -fps_mode support) and fall back to -vsync vfr for ffmpeg < 5.1, or document ffmpeg >= 5.1 as a requirement.
  2. Make doctor check the minimum ffmpeg version / option support, not only encoder availability.
  3. When the ffmpeg child exits early, surface its stderr and exit code instead of only ffmpeg write failed: Broken pipe.

Source: vercel-labs/agent-browser