ffmpeg and AVFoundation

Dear Lazyweb, what magic incantations should I be using to make audio not drop out when doing:

ffmpeg -f avfoundation -i ":iShowU Audio Capture" -acodec libmp3lame -ab 128k -f mp3 -

I had been using Nicecast to capture and stream audio for approximately a thousand years, but they dropped support for that a couple years ago, and I'm finally being dragged into the future. They recommend replacing it with their other product, Audio Hijack, but Audio Hijack has no automation support (not even basic AppleScript) so it's useless to me. You can't even switch input sources from a script. (And yeah, I confirmed this with tech support.)

So we're back to ffmpeg. The hieroglyphics above work, mostly, but every few minutes the audio drops out for several seconds (with no error message printed) and it also, surprisingly, seems to get extra wonky whenever two audio sources are playing at once (e.g. when jwztv is doing a crossfade between two videos).

You can give a listen to the fuckery I am experiencing right now if you tune in to the DNA audio webcast at any time that the video webcast is showing music videos, e.g. right now and most mornings and afternoons.

Audio is clean in the OBS-encoded MP4 stream, so it's not a problem with the device itself.

Other suggestions on how to extract continuous 128kbps MP3 data from an arbitrary macOS audio device (to stdout or to a local icecast server) will also be entertained.

Update: I also tried "-b:a" in case that's not an exact synonym for "-ab", and tried having ffmpeg write directly to the Icecast server with:
-f mp3 -content_type audio/mpeg "icecast://source:PASS@HOST:8000/MOUNTPOINT"
and it has the same problems.


Tags: , , , , , ,

  • Previously