Note, Before figuring out this line above, I had previously tried arecord and aplay as per the example below (arecord -D hw:1,0 -r 32000 -c 2 -f S16_LE | aplay -) and that didn't work as well as I had expected.

Note, Before figuring out this line above, I had previously tried arecord and aplay as per the example below (arecord -D hw:1,0 -r 32000 -c 2 -f S16_LE | aplay -) and that didn't work as well as I had expected.

+

+

Additional Note, After Further Testing today (31/12/12),I have noticed that my line above causes audio sync issues, probably due to the capture audio rate been set to high in comparison to the SAA7134 default audio rate of 32000 and Mplayers default output audio rate of 32000, so this is a correction edit that applies to both lines.

I have recorded a good few gigabytes with this line from my Virginmedia V+HD box

I have recorded a good few gigabytes with this line from my Virginmedia V+HD box

Revision as of 18:28, 31 December 2012

Also see the Saa7134-alsa redundant article; whose info (if it is not redundant) should/will be merged (preferably by its authour so that proper user attribution is maintained for information additions) into this original existing article.

To then load the new driver that lets you get sound off the PCI bus via ALSA or OSS, you would normally just issue "sudo modprobe saa7134-alsa" or "sudo modprobe saa7134-oss". You can also deliberately assign the enumeration; for instance, for four cards, do this for alsa:

If you're using a satellite box, $channel should probably be set to 3 or 4. If that doesn't work, try the US cable TV setup below.
If you're getting your broadcast off the air, you can run the scantv utility to detect stations and set $channel to the local channel for your area.

Note the norm= and chanlist= parameters. Adjust as required for your location.

If "adevice=hw.1,0" doesn't work, try simply "adevice=hw.1". Some tuners require "adevice=hw.2" -- for instance, on a board with nforce 3 250/gb chipsets. If others experiance this with other boards, please update.

Record with mencoder

It may be simpler to get sound during recording than during playback. I get good sound using this, where $DEV is the number of the device node:

So the alsa device is simply called hw.1 -- not hw.1,0. The line is taken from the V4L channel script. You may find you need to use hw.2 instead, depending on the audio hardware on your system.

Neither ffmpeg nor transcode as yet have ALSA support.

Because so many applications still appear to have difficulties accessing ALSA's odd device enumeration, the OSS module for DMA sound continues to be useful. You can also use ALSA's OSS emulation with saa7134-alsa to get /dev/dspX devices for OSS-aware applications.

Using with Mplayer, Mencoder with Gentoo default Pulseaudio and Alsa config

If you are using default SAA7134 Pulseaudio settings (Analog Stero Input with the video channel being captured) as I do, this is my line (Note, these lines are for composite capture) :

Note, Before figuring out this line above, I had previously tried arecord and aplay as per the example below (arecord -D hw:1,0 -r 32000 -c 2 -f S16_LE | aplay -) and that didn't work as well as I had expected.

Additional Note, After Further Testing today (31/12/12),I have noticed that my line above causes audio sync issues, probably due to the capture audio rate been set to high in comparison to the SAA7134 default audio rate of 32000 and Mplayers default output audio rate of 32000, so this is a correction edit that applies to both lines.

I have recorded a good few gigabytes with this line from my Virginmedia V+HD box

These lines were created with the help of this very page and the Mplayer/Mencoder manual.

ALSA audio with other applications

To hear the audio through ALSA using tvtime (or other programs that don't support it directly), run the following command after starting tvtime:

arecord -D hw:1,0 -r 32000 -c 2 -f S16_LE | aplay -

It basically records at 32kHz Stereo from the SAA7134 ALSA source (hw:1,0 or change accordingly), and plays it through your default ALSA output. Look at the options from aplay to change your output.

There might be a delay between the video and the audio. To avoid it, specify a device for aplay (not the 'default' device):

arecord -D hw:1,0 -r 32000 -c 2 -f S16_LE | aplay -D surround41

In order to get full surround sound from the stereo TV audio output, edit your /etc/asound.conf or ~/.asoundrc file as described in ALSA FAQ028 (http://alsa.opensrc.org/FAQ028) and use this device:

arecord -D hw:1,0 -r 32000 -c 2 -f S16_LE | aplay -D ch51dup

I don't know how to use ALSA directly with xawtv, motv, kdtv, tvtime, or zapping; if you do, please add it in here!

If using arecord still causes a delay between the video and the audio, try using sox:

sox -r 32000 -w -t alsa hw:1,0 -t alsa hw:0,0

Recent versions of sox no longer accept "-w" option, so just omit it. You can also use "--buffer" option to improve A/V synchronization, as the default 8KB buffer causes audio to lag significantly. On my system 2KB buffer is optimal:

sox --buffer 2048 -r 32000 -t alsa hw:1,0 -t alsa hw:0,0

Sox might get you mono sound, while all the alsa solutions cause delays. A combination has been known to work:

Howto use Saa7134-alsa with Pulseaudio based-system

Redirect the sound with pulseaudio loopback module

If your Saa713x device is properly configured and still can get no sound with TVTime, you may to redirect the input source from your TV card to the output of your sound card. You must load the loopback module with the command:

$ pactl load-module module-loopback

It will redirect the default input to the default output. The default input may not be the right one, you can change it in the 'Recording' tab with 'All Streams' displayed with Pulseaudio Volume Control (pavucontrol)

Example of loopback module selection in Pulseaudio Volume Control

The sound should now works. To automate the process, we will edit /etc/pulse/default.pa

First we need to now what is the TV card source name in pulseaudio. You can know the PCI address of your card with