# Recording internal sound with snd_hda and ffmpeg



## ManaHime (Feb 6, 2012)

Hi,

I'm trying to record the sound from my system with multimedia/ffmpeg. I've been trying with snd_hda and the new sound driver that is coming soon but all I get is always noises like when you watched parasite on television a long time ago. Is it a normal behavior and is there something I can do to have clear sound? (Ah by the way I'm trying to use pcm4 because that's what my speakers are plugged in)
I'm trying to record with this command
`$ ffmpeg -f oss -i /dev/dsp output.mp3`


`$ uname -a`

```
FreeBSD nyuu 9.0-STABLE FreeBSD 9.0-STABLE #0 r230922M: Thu Feb  2 16:53:20 EST 2012     
root@nyuu:/usr/obj/usr/src/sys/GENERIC  amd64
```

`$ mixer`

```
Mixer vol      is currently set to 100:100
Mixer pcm      is currently set to 100:100
Mixer speaker  is currently set to  75:75
Mixer line     is currently set to   0:0
Mixer mic      is currently set to   0:0
Mixer mix      is currently set to 100:100
Mixer rec      is currently set to 100:100
Mixer igain    is currently set to   0:0
Mixer ogain    is currently set to   0:0
Recording source: mix
```

`$ dmesg | grep hda`

```
hdac0: HDA Codec #0: NVidia (Unknown)
hdac0: HDA Codec #1: NVidia (Unknown)
hdac0: HDA Codec #2: NVidia (Unknown)
hdac0: HDA Codec #3: NVidia (Unknown)
pcm0: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 0 nid 1 on hdac0
pcm1: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 1 nid 1 on hdac0
pcm2: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 2 nid 1 on hdac0
pcm3: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 3 nid 1 on hdac0
hdac1: HDA Codec #2: Realtek ALC892
pcm4: <HDA Realtek ALC892 PCM #0 Analog> at cad 2 nid 1 on hdac1
pcm5: <HDA Realtek ALC892 PCM #1 Analog> at cad 2 nid 1 on hdac1
pcm6: <HDA Realtek ALC892 PCM #2 Digital> at cad 2 nid 1 on hdac1
pcm7: <HDA Realtek ALC892 PCM #3 Digital> at cad 2 nid 1 on hdac1
hdac0: <NVidia (Unknown) HDA Controller> mem 0xf3000000-0xf3003fff irq 17 at device 0.1 on pci1
hdac1: <Intel Cougar Point HDA Controller> mem 0xf3420000-0xf3423fff irq 22 at device 27.0 on pci0
hdacc0: <NVidia (Unknown) HDA CODEC> at cad 0 on hdac0
hdaa0: <NVidia (Unknown) HDA CODEC Audio Function Group> at nid 1 on hdacc0
pcm0: <NVidia (Unknown) HDA CODEC PCM (DisplayPort 8ch)> at nid 5 on hdaa0
hdacc1: <NVidia (Unknown) HDA CODEC> at cad 1 on hdac0
hdaa1: <NVidia (Unknown) HDA CODEC Audio Function Group> at nid 1 on hdacc1
pcm1: <NVidia (Unknown) HDA CODEC PCM (DisplayPort 8ch)> at nid 5 on hdaa1
hdacc2: <NVidia (Unknown) HDA CODEC> at cad 2 on hdac0
hdaa2: <NVidia (Unknown) HDA CODEC Audio Function Group> at nid 1 on hdacc2
pcm2: <NVidia (Unknown) HDA CODEC PCM (DisplayPort 8ch)> at nid 5 on hdaa2
hdacc3: <NVidia (Unknown) HDA CODEC> at cad 3 on hdac0
```


----------



## mav@ (Feb 6, 2012)

Most of HDA CODECs are unable to record playback sound, so snd_hda doesn't support it. 'mix' recording source is input mixer. Even if it somehow includes signal from playback, snd_hda will try to block it, same as other paths it can't handle. The only way is to connect loopback cable between output and line-in, or look for a software-only way to do it.


----------



## adamk (Feb 6, 2012)

For a software only way, I use pulseaudio: http://forums.freebsd.org/showpost.php?p=151327&postcount=2

It's a little complicated to set up, but works well.  Once set up, you don't have to mess with it again.

Adam


----------

