I have a problem with ffmpeg giving no audio when recording using alsa.

Does anyone know how to get a Raspberry Pi Zero W to record and stream audio with ffmpeg using alsa?

I have a project where I am using I2S digital microphones hooked up to an Raspberry Pi Zero W. The microphones are from Adafruit, and I set them up using this guide. I have two microphones set up in stereo mode. Now, when I use

arecord -D plughw:1 -c2 -r 48000 -f S32_LE -t wav -V stereo -v file_stereo.wav

everything works great. I can copy the file over to my main machine and it plays fine. Now, when I try something like this:

ffmpeg -f alsa -re -i hw:1,0 -acodec mp2 -ac 2 -f rtp rtp://[host]:[port]

and try playback via either VLC or ffplay, I only get silence and/or clicking sounds. ffplay indicates that a connection is being made, so it isn't a network issue. I have also verified that the input device is in fact the correct one. I have attempted just replicating arecord through ffmpeg with

ffmpeg -f alsa -i plughw:1,0 -t 10 out.wav

However, this does the same as piping it through RTP. I have tried different codecs: mp2, mp3, aac. I even tried different input and output sampling rates, channels, etc. Nothing works. I have used the ffmpeg available in the Stretch repositories and compiled it myself where I knew it had the alsa library enabled.

Any help would be appreciated!

  • have you tried -ac 2 -ar 48000 input options instead of -re - in the documentation for -re it says Should not be used with actual grab devices or live input streams – Jaromanda X Apr 29 '18 at 23:08
  • Brodi, did you ever figure out a solution for this? I have the same setup and am also getting empty recordings when trying to use ffmpeg. – Logan Aug 10 '19 at 22:43
  • I ended up finding this forum post which contains some working examples of piping arecord to ffmpeg, which is the best option I've been able to find so far: raspberrypi.org/forums/viewtopic.php?t=173809 – Logan Aug 10 '19 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.