You are not logged in.

#1 2010-04-12 09:57:06

drsjlazar
Member
From: Kasama
Registered: 2009-10-01
Posts: 133
Website

ffmpeg can't record audio

I am trying to record audio with ffmpeg but it doesn't seems to detect my sound card. I am running Arch 64bit with KDE. Any ideas?

ffmpeg -f alsa -i /dev/dsp out.wav
FFmpeg version SVN-r22511, Copyright (c) 2000-2010 the FFmpeg developers
  built on Mar 13 2010 19:35:54 with gcc 4.4.3
  configuration: --prefix=/usr --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libfaac --enable-libfaad --enable-libxvid --enable-libx264 --enable-libtheora --enable-postproc --enable-shared --enable-pthreads --enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-version3 --enable-nonfree --enable-runtime-cpudetect
  libavutil     50.12. 0 / 50.12. 0
  libavcodec    52.59. 0 / 52.59. 0
  libavformat   52.55. 0 / 52.55. 0
  libavdevice   52. 2. 0 / 52. 2. 0
  libswscale     0.10. 0 /  0.10. 0
  libpostproc   51. 2. 0 / 51. 2. 0
ALSA lib pcm.c:2211:(snd_pcm_open_noupdate) Unknown PCM /dev/dsp
[alsa @ 0xcf53c0]cannot open audio device /dev/dsp (No such file or directory)
/dev/dsp: I/O error occurred
Usually that means that input file is truncated and/or corrupted.

Offline

#2 2010-04-12 14:53:17

Cr0k
Member
Registered: 2009-10-16
Posts: 174

Re: ffmpeg can't record audio

Apparently, your /dev/dsp doesn't exist.
Look if you didn't desactivate it, I had a similar with my webcam, it was just turned off.

Offline

#3 2010-04-12 15:11:50

drsjlazar
Member
From: Kasama
Registered: 2009-10-01
Posts: 133
Website

Re: ffmpeg can't record audio

It does exist and other apps can use sound just fine. What did you do to activate /dev/dsp?

[me@arch ~]$ ls -al /dev/dsp 
crw-rw----+ 1 root audio 14, 3 Apr 11 02:07 /dev/dsp
[me@arch ~]$ groups 
wheel network video audio optical storage users vboxusers
[me@arch ~]$ lsof | grep /dev/snd
amarok     5083 shane  mem       CHR              116,5               5192 /dev/snd/pcmC0D0p
amarok     5083 shane   13u      CHR              116,9       0t0     5238 /dev/snd/controlC0
amarok     5083 shane   57r      CHR              116,2       0t0     4827 /dev/snd/timer
amarok     5083 shane   62u      CHR              116,5       0t0     5192 /dev/snd/pcmC0D0p
knotify4  26668 shane   12u      CHR              116,9       0t0     5238 /dev/snd/controlC0
kmix      26702 shane   11u      CHR              116,9       0t0     5238 /dev/snd/controlC0

Offline

#4 2010-04-12 15:25:03

wonder
Developer
From: Bucharest, Romania
Registered: 2006-07-05
Posts: 5,941
Website

Re: ffmpeg can't record audio

/dev/dsp is a oss device and not alsa.

you might want to do something like:

ffmpeg -f alsa -ac 2 -i hw:0,0 out.wav

or directly mp3

ffmpeg -f alsa -ac 2 -i hw:0,0 -acodec libmp3lame -ab 192k out.mp3

Give what you have. To someone, it may be better than you dare to think.

Offline

#5 2010-04-12 16:47:26

drsjlazar
Member
From: Kasama
Registered: 2009-10-01
Posts: 133
Website

Re: ffmpeg can't record audio

Salut smile

I tried that before. Some change using hw:0,0 but it still doesn't work... I get device busy error even after exiting all apps using the sound card.

[me@arch ~]$ cat /proc/asound/cards 
 0 [Intel          ]: HDA-Intel - HDA Intel
                      HDA Intel at 0xf4800000 irq 21
[me@arch ~]$ lsof | grep /dev/snd
[me@arch ~]$ ffmpeg -f alsa -ac 2 -i hw:0,0 out.wav
FFmpeg version SVN-r22511, Copyright (c) 2000-2010 the FFmpeg developers
  built on Mar 13 2010 19:35:54 with gcc 4.4.3
  configuration: --prefix=/usr --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libfaac --enable-libfaad --enable-libxvid --enable-libx264 --enable-libtheora --enable-postproc --enable-shared --enable-pthreads --enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-version3 --enable-nonfree --enable-runtime-cpudetect
  libavutil     50.12. 0 / 50.12. 0
  libavcodec    52.59. 0 / 52.59. 0
  libavformat   52.55. 0 / 52.55. 0
  libavdevice   52. 2. 0 / 52. 2. 0
  libswscale     0.10. 0 /  0.10. 0
  libpostproc   51. 2. 0 / 51. 2. 0
[alsa @ 0xe6c3c0]cannot open audio device hw:0,0 (Device or resource busy)
hw:0,0: I/O error occurred
Usually that means that input file is truncated and/or corrupted.

Offline

#6 2010-04-13 00:08:32

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: ffmpeg can't record audio

You can find out what alsa devices are usable with:

arecord -l

On my system:

~ > arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: SB [HDA ATI SB], device 0: ALC888 Analog [ALC888 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: SB [HDA ATI SB], device 2: ALC888 Analog [ALC888 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

So both hw:0,0 and hw:0,2 are good values. I believe that this will only work if you have capturing set up your alsa config files.

Offline

#7 2010-04-13 00:28:34

drsjlazar
Member
From: Kasama
Registered: 2009-10-01
Posts: 133
Website

Re: ffmpeg can't record audio

Actually, I'm trying to do some screen casting / recording with ffmpeg. I've got the video part sorted out and facing this problem with audio. I guess I'll have to read up on alsa. I don't have a /etc/asound.conf file... but haven't had problems with sound up to now. I've tried other methods for screen recording (recordmydesktop and xvidcap) but neither gives the video quality of ffmpeg.

Offline

#8 2010-07-07 19:40:35

madeye
Member
From: Denmark
Registered: 2006-07-19
Posts: 331
Website

Re: ffmpeg can't record audio

Maybe a little late for an answer, but I thought it couldn't hurt to list what I did to solve a similar situation.

Unfortunately I'm not smart enough to do this the "programming" way, so I did it the "old fashioned way".

The line out from my sound card is connected to my amplifier (tuner input). I then route the signal back to the computer using the tape rec out connector. This is connected to the line in on my sound card.

Using the volume control in Gnome I set the 1st input source to Line on the options tab. Then on the recording tab I activate the capture channel (make sure it's only for recording, not playback!) and set the recording level.

Now I am able to use

ffmpeg -f alsa -ac 2 -i hw:0,0 -acodec pcm_s16le output.wav

to capture the sound.

It's even possible to use audacity if you set the recording device to hw:0,0


MadEye | Registered Linux user #167944 since 2000-02-28 | Homepage

Offline

Board footer

Powered by FluxBB