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
]]>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.
]]>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.
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
[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
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.