1

I have a Raspberry Pi 3 and I keep trying to install FFMPEG, but whenever I try to record audio through my USB webcam's mic with

sudo ffmpeg -f alsa -i hw:1 -t 30 out.wav

I get the following error:

ffmpeg version N-86882-gc0220c7 Copyright (c) 2000-2017 the FFmpeg developers

   built with gcc 4.9.2 (Raspbian 4.9.2-10)
   configuration:
   libavutil 55. 69.100 / 55. 69.100
   libavcodec 57.102.100 / 57.102.100
   libavformat 57. 76.100 / 57. 76.100
   libavdevice 57. 7.100 / 57. 7.100
   libavfilter 6. 95.100 / 6. 95.100
   libswscale 4. 7.101 / 4. 7.101
   libswresample 2. 8.100 / 2. 8.100
Unknown input format: 'alsa'

From a fresh install of Raspbian, I installed ffmpeg in the instructions I found [here]:

$ cd /usr/src
$ sudo git clone git://source.ffmpeg.org/ffmpeg.git
$ cd ffmpeg/
$ sudo ./configure && sudo make && sudo make install

I also tried these instructions:

$ git clone --depth 1 git://git.videolan.org/x264
$ cd x264
$ ./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl
$ make -j 4
$ sudo make install
$ git clone --depth=1 git://source.ffmpeg.org/ffmpeg.git
$ cd ffmpeg
$ ./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree
$ make -j4
$ sudo make install

As well as this:

$ wget http://ffmpeg.org/releases/ffmpeg-3.3.3.tar.bz2
$ tar -xvf ffmpgeg-3.3.3.tar.bz2
$ cd ffmpeg-3.3.3
$ ./configure
$ make
$ sudo make install

But I always get the same error, with varying results on the version number of ffpmeg. I know the webcam's mic is working because I can record with

arecord -D plughw:1,0 -f cd test.wav

I have thought of piping arecord to ffmpeg like here, but I keep getting other errors and I feel this is going AROUND the problem rather than solving it.

I see that another question like this was posted [here].

Other references:

3
+50

Short answer

run:

sudo apt-get install libasound2-dev

before attempting to configure and compile ffmpeg or anything where you need alsa support.

Process for resolving similar build dependencies:

Returning to this build/install method:

$ cd /usr/src
$ sudo git clone git://source.ffmpeg.org/ffmpeg.git
$ cd ffmpeg/
$ sudo ./configure && sudo make && sudo make install

the last line is a compaction of three steps, and the first one is significant as configure establishes what optional features the binary will support.

It is normal to change system libraries and configuration options and rerun configure many times until you are happy with its results.

The output you want is "alsa" as a supported indev (and probably outdev.)

./configure
  ... no alsa .. 
./configure --help
./configure --list-indevs
./configure --enable-indev=alsa --enable-outdev=alsa
  ... no alsa .. so it is not just off by default..
grep alsa configure
      alsa_asoundlib_h
      alsa
  alsa_indev_deps="alsa"
  alsa_outdev_deps="alsa"
  enabled_any alsa_indev alsa_outdev &&
      check_lib alsa alsa/asoundlib.h snd_pcm_htimestamp -lasound

this leads to why configure is not supporting alsa, and looking up asoundlib.h goes here though you could also query the packaging db.

sudo apt-get install libasound2-dev
./configure
 ... alsa! ..
./make
./ffmpeg -formats |grep alsa
 ...  DE alsa! .. (the D/E columns indicate both directions are working)
./make install
  • I am seeing what you are saying, when I run "./ffmpeg -formats |grep alsa" I see the DE alsa, but now it says "[alsa @ 0x17261e0] cannot set channel count to 2 (Invalid argument) hw:1: Input/output error" when I try to record – Quintin Balsdon Jul 31 '17 at 23:27
  • Nevermind, I just had to modify the command to "sudo ffmpeg -f alsa -ac 1 -i hw:1 -t 30 out.wav" Thank you! – Quintin Balsdon Jul 31 '17 at 23:33
  • Can only award bounty in 13 hours, but it's yours. Thanks again for a superb answer! – Quintin Balsdon Jul 31 '17 at 23:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.