Ffmpeg Capture
Context: $ARGUMENTS
Quick start
- Record the screen: → Step 1 (list devices) → Step 2 (pick source) → Step 3 (run)
- Record webcam + mic: → Step 1 → Step 3 with
webcamsubcommand - Record a region: → Step 3 with
--crop(mac/linux) or-offset_x/-offset_y/-video_size(Windows gdigrab) - Record system audio (mac): install BlackHole first → Step 2 (route via virtual device)
- Just list devices:
python3 scripts/capture.py list-devices
When to use
- User wants a screencast, demo recording, or desktop capture to a file.
- User wants to record webcam/microphone/system audio to disk.
- User wants to enumerate which cameras/mics/screens ffmpeg can see.
- User wants low-latency or crash-safe recording (MKV-first, remux to MP4 after).
Do NOT use for: streaming to RTMP/HLS (use ffmpeg-streaming), applying filters/effects (use ffmpeg-video-filter), or converting an existing file (use ffmpeg-transcode).
Step 1 — Detect platform + list devices
Always list devices first. Names and indices are shown in the format ffmpeg expects them.
macOS (avfoundation):
ffmpeg -f avfoundation -list_devices true -i ""
Output has two sections: AVFoundation video devices: (cameras + screens, screen is usually the last one with Capture screen 0) and AVFoundation audio devices:. Indices reset between the two lists — video 1 and audio 0 are unrelated.
Windows (dshow for camera/mic, gdigrab for desktop):
ffmpeg -list_devices true -f dshow -i dummy
ffmpeg -list_options true -f dshow -i video="HD Webcam"
gdigrab needs no enumeration — input name is always desktop (or title=Window Name).
Linux:
# Cameras
v4l2-ctl --list-devices
ffmpeg -f v4l2 -list_formats all -i /dev/video0
# Audio (Pulse)
pactl list sources short
# Audio (ALSA)
arecord -L
# Display (X11)
echo "$DISPLAY" # usually :0.0 or :1.0
Or run the helper: python3 scripts/capture.py list-devices (auto-detects platform).
Step 2 — Pick source + audio route
Decide: