10

I'd like to record audio from my microphone. My OS is ubuntu. I've tried the following and got errors

$ ffmpeg -f alsa -ac 2 -i hw:1,0 -itsoffset 00:00:00.5 -f video4linux2 -s 320x240 -r 25 /dev/video0 out.mpg

ffmpeg version 0.8.8-4:0.8.8-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav
developers
  built on Oct 22 2013 12:31:55 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release.
Please use avconv instead.
ALSA lib conf.c:3314:(snd_config_hooks_call) Cannot open shared library
libasound_module_conf_pulse.so
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM hw:1,0
[alsa @ 0xbda7a0] cannot open audio device hw:1,0 (No such file or directory)
hw:1,0: Input/output error

Then I tried

$ ffmpeg -f oss -i /dev/dsp audio.mp3

ffmpeg version 0.8.8-4:0.8.8-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav
developers
built on Oct 22 2013 12:31:55 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release.
Please use avconv instead.
[oss @ 0x1ba57a0] /dev/dsp: No such file or directory
/dev/dsp: Input/output error

I haven't been able to get ffmpeg to find my microphone. How can I tell ffmpeg to record from my microphone?
It seems the 'Deprecated' message can be ignored because of this topic

Community
  • 1
  • 1
Conor Patrick
  • 2,529
  • 5
  • 17
  • 32

3 Answers3

10

I realise this is a bit old. Just in case anyone else is looking:

ffmpeg -f alsa -ac 2 -i default -itsoffset 00:00:00.5 -f video4linux2 -s 320x240 -r 25 -i /dev/video0 out.mpg

This way it will use the default device to record from. You were also missing a -i before the video capture device - /dev/device0

If you want to get more specific you should take a look in /proc/asound. Check the cards, devices, pcm files and the card subdirectories. You should be able to glean enough information there to be able to make an educated guess; e.g hw:1,0 or hw:2,0

The documentation may provide further clues:

The same goes for the webcam - it may not be /dev/video0, perhaps you have an external webcam plugged in and its at /dev/video1 - Have a look in the /dev directory and see whats available

GreenGuerilla
  • 351
  • 4
  • 6
  • 2
    When using pulse audio, it's useful to be able to select exactly which audio device to record. `ffmpeg -sources pulse` will list the available pulse sources. In my case the one I wanted was the system's default mixed sound output device (`alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo.monitor`). The ffmpeg command then becomes: `ffmpeg -i pulse -ac 2 -i 'alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo.monitor'` – Cosimo Nov 18 '20 at 11:41
2

solved !

ffmpeg -f pulse -ac 2 -i default -f x11grab -r 30 -s 1920x1080 -i :0.0 -acodec pcm_s16le -vcodec libx264 -preset ultrafast -threads 0 -y /media/t/TBVolume/desktop/output.mkv 
tatsu
  • 21
  • 2
  • 8
    It would be helpful to others to also provide a brief description explaining how this solves the problem. – Leigh Dec 07 '14 at 19:25
0

First, list your AV devices using:

ffmpeg -list_devices true -f dshow -i dummy

Assuming your audio device is "Microphone Array", you can use:

ffmpeg -f dshow -i audio="Microphone Array" -c:a libmp3lame -b:a 128k OUTPUT.mp3

Here, 128k is the sampling rate. You can check all options for sampling rates (CBR) here.

CRTejaswi
  • 19
  • 3