Streaming audio recorded by USB mic on the web

Tldr: Live streaming audio on the web.

I'm recording sound captured by an USB mic and it works fine when I want to playback it through my headset but I'd like to stream it in real time and serve it on my website.

I came across Mopidly which is a music server written in Python. Looked like a sound solution to this if it wasn't for the fact that it uses its own dedicated port. Meaning anything on the web would be served on port 8000 and audio on another port 'coz you can't have 2 servers be servicing same port. But that's exactly what I need.

How people achieve that these days ?

Answers 1

  • I use VLC package. It's standard on Buster.

    cvlc alsa://plughw:1,0 --sout '#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access=http,mux=mp3,dst=:8087}'

    This streams my webcam mic on [http://localhost:8087].

    If you are on another machine within your subnet you should be able to substitute "localhost" with the IP4 of the Pi and pull down that stream. To access it on the internet (outside your subnet) there are many ways (secure and insecure) which would constitute another question.

    My suggestion would be forwarding a port over SSH. But it's doable and easy.

Related Questions