2

So I think the title explains most of this, I am trying to record my screen on macOS catalina using ffmpeg while directing the audio in using blackhole

I am getting audio in but the sound is crackling, almost sounds like a lag or buffer or something like that.

I am using the command:

ffmpeg -f avfoundation -list_devices true -i ""

Which gives me:

[AVFoundation indev @ 0x7fcf87f06480] AVFoundation video devices:
[AVFoundation indev @ 0x7fcf87f06480] [0] FaceTime HD Camera (Built-in)
[AVFoundation indev @ 0x7fcf87f06480] [1] Capture screen 0
[AVFoundation indev @ 0x7fcf87f06480] [2] Capture screen 1
[AVFoundation indev @ 0x7fcf87f06480] AVFoundation audio devices:
[AVFoundation indev @ 0x7fcf87f06480] [0] BlackHole 2ch
[AVFoundation indev @ 0x7fcf87f06480] [1] Built-in Input
[AVFoundation indev @ 0x7fcf87f06480] [2] BlackHole 16ch

I then run

ffmpeg -f avfoundation -pix_fmt yuyv422 -i "1:0" -ac 2 -ar 48000 -t 20 -vf crop=1280:720:1:65 -r 30 /Users/XXX/Desktop/ScreenRecordings/test2.mkv

which records as expected video is good but it has the bad sound as described.

Note:

  1. Audio recording with quiktime works perfectly
  2. Yes, I am rerouting the computer's audio to blackhole 2ch before I run the ffmpeg command
  3. In the midi sound devices menu I set the output to 48,000 for blackhole 2ch

Does anyone know how to fix the audio?

7
  • What happens if you set it to 44.1k instead. You've got either 'too much data' to convert or a frequency/rate mismatch somewhere. I've never used Blackhole, I went straight from Soundflower to Rogue Amoeba, years & years ago.
    – Tetsujin
    Nov 11, 2020 at 10:59
  • Then why not just use Quicktime & convert afterwards? I think you're hitting a processing limit somewhere. Recording screen & transcoding simultaneously is going to be quite a hit on even a high-end machine. If you're trying to do this on a laptop, especially one with on-chip graphics, I think you're going to struggle.
    – Tetsujin
    Nov 11, 2020 at 11:09
  • to your question, at 44100 i get chipmunk robotic type voices, quite creepy. The thing is I hoped to set this in an automated script to begin recording at a specific time. Do you think if I go to lower resolutions i might have more success? I have seen it done at this link (with, I think a pretty basic machine) youtube.com/watch?v=mEV2O8C272g&t=45s I actually think that you are right about the ar/freq discrepancies
    – Nebulloyd
    Nov 11, 2020 at 11:12
  • I have also tried just recording audio in this manner to test whether it is overloading my system and it gives the same problem
    – Nebulloyd
    Nov 11, 2020 at 11:32
  • Then it may have something to do with Blackhole. I've never used it, so idk, sorry.
    – Tetsujin
    Nov 11, 2020 at 11:37

1 Answer 1

2

I am unable to get anything out of FFMPEG that's not a mess of crackles. I tried Soundflower, BlackHole and Rogue Amoeba's Loopback trial. A couple of Google results implied that FFMPEG v4.2 might be OK with later versions causing trouble (current latest at time of writing is v4.4), but v4.2 was no different for me.

The solution I ended up with was:

  • Use sox instead of ffmpeg, e.g. installed via Homebrew
  • Install BlackHole 2-channel - https://github.com/ExistentialAudio/BlackHole
  • I use AudioSwitcher (https://apps.apple.com/us/app/audioswitcher/id561712678) to easily switch devices, but System Preferences works too and there are FOSS solutions if you dig around
  • If you can't see BlackHole as a system audio output device, then in Audio MIDI Setup, create an aggregate device with an easy to type name and you should be able to select that instead

At this point, you should be all set. Record with e.g.:

sox -t coreaudio "BlackHole 2ch" ~/foo.flac  

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .