List macOS Screen Capture Devices in FFmpeg

This guide explains how to identify and list available video and screen capture devices on macOS using FFmpeg and the native AVFoundation framework. By utilizing a specific command-line flag, you can view the indices assigned to your connected monitors and cameras, allowing you to accurately target screens for recording or streaming tasks.

The Device Listing Command

On macOS, FFmpeg interfaces with hardware through the avfoundation device demuxer. To query the system for all connected input devices, open your Terminal and run the following command:

ffmpeg -f avfoundation -list_devices true -i ""

Understanding the Output

FFmpeg will query macOS and return an error code (which is expected, as no valid input file was specified), but it will print the discovered hardware list to the terminal under AVFoundation video devices and AVFoundation audio devices.

The output will look similar to this:

[AVFoundation indev @ 0x7fa2b6604e80] AVFoundation video devices:
[AVFoundation indev @ 0x7fa2b6604e80] [0] FaceTime HD Camera
[AVFoundation indev @ 0x7fa2b6604e80] [1] Capture screen 0
[AVFoundation indev @ 0x7fa2b6604e80] [2] Capture screen 1
[AVFoundation indev @ 0x7fa2b6604e80] AVFoundation audio devices:
[AVFoundation indev @ 0x7fa2b6604e80] [0] Built-in Microphone

In this output:

  • Entries named "Capture screen X" represent your physical monitors.
  • The number enclosed in brackets (e.g., [1]) is the device index used to reference that screen in FFmpeg commands.

Using the Discovered Screen Device

Once you have identified the index of the screen you wish to capture, reference it using the -i "<video_index>:<audio_index>" syntax.

To capture only the screen without audio (assuming "Capture screen 0" corresponds to index 1):

ffmpeg -f avfoundation -i "1:none" -r 30 output.mp4

To capture both the screen (index 1) and the built-in microphone (index 0):

ffmpeg -f avfoundation -i "1:0" -r 30 output.mp4

macOS Permissions

If no screen devices appear in the list, verify that your terminal emulator (such as Terminal or iTerm) has permission to record the display. Navigate to System Settings > Privacy & Security > Screen Recording, and ensure your terminal application is enabled.