2

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.

big samon
  • 21
  • 2
  • Welcome to Ask Different. It would help us if you provided additional info, such as the types of devices, OS, etc. Also let us know what you've already done, specifically, to solve the problem yourself. Please see [ask] for how to ask good questions that have a better chance at being answered. – fsb Jan 29 '20 at 20:00
  • Is this screencapture on Catalina? Also, see this post for obtaining AV devices using ffmpeg: https://apple.stackexchange.com/questions/326388/terminal-command-to-record-audio-through-macbook-microphone/326390#326390 – Allan Jan 30 '20 at 04:56
  • @Allan unfortunately, ffmpeg doesn't print device IDs suitable for screencapture. – uasi Feb 08 '21 at 17:44

1 Answers1

3

The -A <id> option has been replaced by the -G <id> 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("device=(device.localizedName), id=(device.uniqueID)") }

# 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
[
  {
    "deviceType" : "AVCaptureDeviceTypeBuiltInMicrophone",
    "isConnected" : true,
    "localizedName" : "MacBook Pro Microphone",
    "manufacturer" : "Apple Inc.",
    "modelID" : "Digital Mic",
    "uniqueID" : "BuiltInMicrophoneDevice"
  },
  ...
]
uasi
  • 151