Sample code: audio capture

Hi all,

I want to create a toy Web App seating on Phoenix to capture audio from the default MIC or a headset and create audio files. Does anybody have a suggestion of a piece of sample code that I can start from? I know how to do this with Django or simply HTML5 but i wanted to see how it may look within Phoenix.
Thanks!

:wave:

Do you want to use a browser to capture the audio or elixir (with a nif, most likely)?

1 Like

Ideally a browser.

If it’s just an experiment, then you probably can send the captured packets over websocket to the elixir app, and process it there either with ffmpeg or “manually” in elixir/erlang (to write to a container like mp3). For the latter you might want to check out the (outdated and abandoned) erlyvideo repo. There’s also https://github.com/membraneframework/membrane-core which seems like a wrapper for ffmpeg, but I haven’t used it yet.

In a more serious project you’d probably want to use webrtc (to make use of udp instead of tcp) to send audio (or any form of real time media) from the browser to the server.

2 Likes