Use Screencapture command to record screen -- How to get the audio source id? I want to write a scheduled script to use the screencapture command to record the screen automatically in the background, just like this:

$ screencapture -v -V 60 output.mov -A xxxx


'xxxx' is the id of the audio source. I have to specify this parameter to record macos internal audio, using a virtual audio device like Soundflower, and without the specified audio source id, the captured videos are always muted.

How could I get all the audio devices' IDs in the simplest way? I tried many apps and scripts but still could not find the solution.
The -A &lt;id&gt; option has been replaced by the -G &lt;id&gt; option. Regarding the ID, it might be SoundflowerEngine:1 or something like that. You can get all audio device IDs by running the following Swift code (requires Xcode to be installed):
import Cocoa
import AVFoundation

let session = AVCaptureDevice.DiscoverySession.init(deviceTypes: [.builtInMicrophone, .externalUnknown], mediaType: nil, position: .unspecified)

for device in session.devices {
    print(&quot;device=\(device.localizedName), id=\(device.uniqueID)&quot;)
}

# Save it as ids.swift, and
$ swift ids.swift
device=MacBook Pro Microphone, id=BuiltInMicrophoneDevice
device=Soundflower (64ch), id=SoundflowerEngine:1

$ screencapture -v -V 60 -G SoundflowerEngine:1 output.mov

Alternatively, you can use the command line tool I made without installing Xcode:
$ list-av-capture-devices
[
  {
    &quot;deviceType&quot; : &quot;AVCaptureDeviceTypeBuiltInMicrophone&quot;,
    &quot;isConnected&quot; : true,
    &quot;localizedName&quot; : &quot;MacBook Pro Microphone&quot;,
    &quot;manufacturer&quot; : &quot;Apple Inc.&quot;,
    &quot;modelID&quot; : &quot;Digital Mic&quot;,
    &quot;uniqueID&quot; : &quot;BuiltInMicrophoneDevice&quot;
  },
  ...
]