Introduction
FFmpeg supports various input devices for capturing live audio and video from hardware sources. Input devices are implemented in thelibavdevice library and registered in alldevices.c.
Usage
Specify input devices using the-f option followed by the device format:
Video Input Devices
v4l2 (Video4Linux2)
Capture video from Video4Linux2 devices on Linux. Platform: Linux Examples:video_size- Set frame sizeframerate- Set frame ratepixel_format- Set pixel formatinput_format- Set input format
dshow (DirectShow)
Capture from DirectShow devices on Windows. Platform: Windows Examples:video_size- Frame sizeframerate- Frame ratepixel_format- Pixel formatrtbufsize- Buffer size for real-time capture
avfoundation
Capture from AVFoundation devices on macOS. Platform: macOS / iOS Examples:framerate- Frame ratevideo_size- Frame sizepixel_format- Pixel formatcapture_cursor- Capture cursorcapture_mouse_clicks- Capture mouse clicks
gdigrab
Capture Windows screen using GDI. Platform: Windows Examples:offset_x,offset_y- Capture offsetvideo_size- Capture sizeframerate- Frame ratedraw_mouse- Show mouse cursor (0 or 1)show_region- Show capture region
xcbgrab
Capture X11 screen using XCB. Platform: Linux (X11) Examples:video_size- Capture sizeframerate- Frame ratedraw_mouse- Show mouse cursorfollow_mouse- Follow mouse: centered, positionselect_region- Interactive region selection
fbdev (Framebuffer)
Capture from Linux framebuffer device. Platform: Linux Examples:kmsgrab
Capture from Linux KMS/DRM. Platform: Linux Examples:android_camera
Capture from Android camera. Platform: Android Examples:decklink
Capture from Blackmagic DeckLink cards. Platform: Cross-platform Examples:list_devices- List available deviceslist_formats- List supported formatsformat_code- Video format code
vfwcap
Video for Windows capture. Platform: Windows (legacy) Examples:lavfi (Libavfilter Virtual Device)
Generate test patterns and virtual video sources. Platform: Cross-platform Examples:Audio Input Devices
alsa (Advanced Linux Sound Architecture)
Capture audio on Linux. Platform: Linux Examples:sample_rate/ar- Sample ratechannels/ac- Number of channels
pulse (PulseAudio)
Capture audio from PulseAudio. Platform: Linux Examples:sample_rate- Sample ratechannels- Number of channelsfragment_size- Audio fragment size
oss (Open Sound System)
Capture audio using OSS. Platform: Linux, BSD Examples:sndio
Capture audio using sndio. Platform: OpenBSD Examples:jack (JACK Audio Connection Kit)
Capture from JACK audio server. Platform: Linux, macOS Examples:channels- Number of channels
openal
Capture audio using OpenAL. Platform: Cross-platform Examples:dshow (DirectShow Audio)
Capture audio on Windows. Platform: Windows Examples:avfoundation (Audio)
Capture audio on macOS. Platform: macOS Examples:Specialized Input Devices
iec61883
Capture from FireWire/IEEE 1394 devices. Platform: Linux Examples:libdc1394
Capture from IIDC/DCAM 1394 devices. Platform: Linux Examples:libcdio
Read audio CDs. Platform: Cross-platform Examples:Device Selection Tips
Linux
- Video: Use
v4l2for webcams,x11grabfor screen capture - Audio: Use
pulse(PulseAudio),alsa, orjack
Windows
- Video: Use
dshowfor webcams,gdigrabfor screen capture - Audio: Use
dshow
macOS
- Video/Audio: Use
avfoundation - Screen capture: Use
avfoundationwith screen input
Common Capture Scenarios
Webcam + Microphone (Windows)
Webcam + Microphone (Linux)
Webcam + Microphone (macOS)
Screen Capture (Windows)
Screen Capture (Linux)
Screen Capture (macOS)
Performance Tips
Reduce Latency
- Use smaller buffer sizes:
-rtbufsize 100M - Lower frame rates for screen capture
- Use hardware encoding when available
Minimize CPU Usage
- Use faster encoding presets:
-preset ultrafast - Lower resolution or frame rate
- Use hardware acceleration
Troubleshooting
See Also
- Output Devices - Output device reference
- Filter System - Apply filters to captured streams
- Video Filters - Process captured video
- Audio Filters - Process captured audio