← back to projects

LyreBirdAudio

Production-hardened RTSP audio streaming from USB microphones

lang Shell license Apache-2.0 view on GitHub →

Highlights

  • Converts USB microphones to RTSP streams at rtsp://host:8554/device-name
  • Persistent device naming across reboots via generated udev rules
  • Automatic hardware capability detection and config generation
  • Self-healing stream recovery with exponential backoff
  • Non-invasive detection that doesn't interrupt devices during discovery
  • Cron-based health checks and git-managed versioning with rollback

Background

There is a class of real-world problem (bioacoustic monitoring, wildlife research, distributed sensing, home audio) where the cheapest practical solution is “plug a USB microphone into a Raspberry Pi and have it stream RTSP.” MediaMTX is the best RTSP server available for that kind of deployment: small, well-maintained, and flexible. Turning a USB microphone into a 24/7 production stream involves quite a lot more than mediamtx.yml, though.

USB device names change on reboot. Enumeration races mean the same physical microphone can come up as hw:1,0 today and hw:2,0 tomorrow. Hardware hot-unplugs happen. Capability detection has to be automatic because the same deployment script runs against a dozen different microphone models. Silent-failure RTSP streams are the norm rather than the exception, so health checks have to be external. The existing launcher scripts covered maybe 30% of that surface area, and the other 70% was left as an exercise for the operator.

LyreBirdAudio started as that other 70% and grew into the glue layer that keeps the stream up.

What LyreBirdAudio adds

Stable device naming through generated udev rules that pin every microphone to a persistent identifier, so rtsp://host:8554/lobby-mic means the same physical device after a reboot or a hot-swap.

Non-invasive capability detection that probes each device without interrupting other active streams, reads its real sample rates and channel counts, and writes a config MediaMTX can actually serve.

A self-healing recovery loop with exponential backoff that restarts failed streams without thrashing the USB bus when a device is intermittently misbehaving.

Cron-driven health checks, because silent-failure RTSP is a real failure mode and nobody wants to discover it from a week-old gap in their recordings.

Git-managed versioning with rollback support, because “the stream stopped working after I made a change” is the most common production incident.

The project ships both an interactive wizard for hobbyists running a single Raspberry Pi and a scriptable installer for operators deploying to a dozen field devices. Same codebase, two audiences.

Design philosophy

LyreBirdAudio is the project on this site that most obviously embodies the “operational reality” theme. “Mostly works” isn’t the same as “works for a year unattended on a $35 computer,” and the difference is exactly the kind of unglamorous failure-handling work that tools like this exist to do.

The Go rewrite (lyrebirdaudio-go) packages the same design into a single static binary for environments that don’t want to run a shell-script bundle. Same logic, different distribution model.