Watching Television on Linux: setting up a TV Tuner card

A couple of weeks back, I went shopping looking for a TV tuner card that is compatible with Linux. Googling had told me that “Hauppauge” card was known to be compatible. However, I could not find it anywhere in the market (SP Road, Bangalore, India). On going to one of the shops, I found a “Pinnacle PCTV 50i” card. I had heard from many people before that Pinnacle was a good card for Windows both in terms of quality of decoding and software provided. I checked in google to ensure that Pinnacle card would work on Linux. I found that the card uses Philips’ SAA7134 chipset for which drivers are available in Linux. I went on and bought the card for Rs 2000 ($50).

Pinnacle PCTV 50i

The card is available through Amazon.com.
Pinnacle PCTV Analog PCI 50i – TV / radio tuner / video input adapter – PCI – SECAM, PAL

Setting up the card in Linux

I have Ubuntu Gutsy installed (7.10) and followed this guide to setup the card and the instructions worked like a charm. A gist of the procedure.

Ubuntu Gutsy recognizes the card automatically, the following commands help to check if the recognition happened or not. Both commands should give atleast one line of output each.

sudo update-pciids
lspci | grep -i saa713
dmesg | grep saa713



Watching TV – tvtime

tvtime is a simple to use application for watching TV on Linux. Here is how you configure it.

sudo apt-get install tvtime
tvtime &


Right click to open a setup menu. You can also hit [F1] or [tab] key to show configuration menu:
Linux Tvtime configuration hit [F1] or [tab] key to show configuration menu
(Fig. 01: Linux tvtime application configuration menu)
First, you need to setup video source, frequencies and channels etc.

Setup video source

Visit Input Configuration > Change Video Source > Setup source as per your setup.

Setup frequencies table

You need to setup the channels you are receiving with the tuner. Here we use europe frequencies table. Visit Channel management > Change Frequency table > Select new table
Scan Channel

Finally, you need to scan for channels by visiting Channel management > Change Frequency table > Scan channels for signal > Back > Exit

Sound configuration

You need to attach internal cables to get sound out of TV tuner card. Use driver saa7134-oss or saa7134-alsa to get sound out of card. This driver get loaded automatically. Open terminal and type the following command to hear the audio through ALSA using tvtime (or other programs that don’t support it directly):

$ sox -c 2 -s -w -r 32000 -t ossdsp /dev/dsp1 -t ossdsp -w -r 32000 /dev/dsp

Recording TV using mencoder

if you do not already have mencoder, you can install it (on Debian/Ubuntu) by doing

Note that the above command will also install mplayer which is useful for viewing video files and tv channels. If you are the command line kind of person, you can do away with tvtime and use mplayer!

To record a TV channel, you will first need to figure out the frequency of the channel. For this I found scantv useful. This command will scan channels in the specified range and print out the found channels. After figuring out the frequency of the channel to record, use this mencoder command to record the video in a compressed format.

mencoder tv:// -tv driver=v4l2:input=0:norm=pal:width=640:height=480:device=/dev/video0:\ 
freq=775.25:adevice=/dev/dsp1:forceaudio:audiorate=32000 buffersize=64\ 
 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=400:keyint=30 -oac mp3lame\  
-lameopts br=32:cbr:mode=3 -ffourcc divx -o "test.avi"


To use mplayer to view TV directly (without using tvtime),do this.

mplayer tv:// -tv driver=v4l2:input=0:norm=pal:width=640:height=480:device=/dev/video0:\
freq=775.25:adevice=/dev/dsp1:forceaudio:audiorate=32000


I've been using this card without a glitch and recommend for HTPC attempts on Linux.

No Trackbacks

31 Comments

  1. nvidia provides good tv tuner cards. they are all in one ,so i guess it will work for Linux

    Posted March 24, 2008 at 2:24 am | Permalink
  2. Hi there! NVIDIA does have TV tuner cards but googling doesn’t paint a good picture for linux compatibility.

    Posted March 24, 2008 at 8:15 pm | Permalink
  3. Ik

    Hi,

    Have anybody tested the same with TATA Sky ?

    Posted March 27, 2008 at 6:25 pm | Permalink
  4. Whether the card works on not is totally independent from the cable operator. If it works for Doordarshan, it should work for Tata Sky too.

    Posted March 27, 2008 at 10:00 pm | Permalink
  5. she

    Nice hint

    does anyone have more info with mencoder?
    Especially with scanning _only_ with mplayer/mencoder?

    tvtime and xawtv are slowly dying :(

    Posted March 30, 2008 at 12:43 am | Permalink
  6. I do not know if mplayer/mencoder can scan channels. I used scantv (http://linux.die.net/man/1/scantv).

    Posted March 31, 2008 at 9:55 pm | Permalink
  7. Krishna

    Hey Prashanth,

    It has worked for me. Thank you very much for the post.

    One query, have you tried Myth TV?

    cheers,
    Krishna

    Posted July 8, 2008 at 10:10 pm | Permalink
  8. Krisha, that’s great. I’ve been intending to but did not get around to doing it.

    Posted July 17, 2008 at 9:37 pm | Permalink
  9. tvtime display fine video and sound
    same with motv

    but I can’t make either mencoder nor mplayer to get the SOUND, they only get video OK, but no SOUND

    they don get nothing from /dev/dsp

    Here is my list of hardware
    lspci
    00:1b.0 Audio device: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) High Definition Audio Controller (rev 03)
    02:04.0 Multimedia controller: Philips Semiconductors SAA7133/SAA7135 Video Broadcast Decoder (rev 10)

    asoundconf list
    Names of available sound cards:
    Intel
    SAA7134

    cat /proc/asound/cards
    0 [Intel ]: HDA-Intel – HDA Intel
    HDA Intel at 0xcfe38000 irq 16
    1 [SAA7134 ]: SAA7134 – SAA7134
    saa7133[0] at 0xcfffe800 irq 16

    lsmod | grep -i snd
    snd_hda_intel 344728 3
    snd_pcm_oss 42144 0
    snd_mixer_oss 17920 1 snd_pcm_oss
    snd_pcm 78596 3 saa7134_alsa,snd_hda_intel,snd_pcm_oss
    snd_page_alloc 11400 2 snd_hda_intel,snd_pcm
    snd_hwdep 10500 1 snd_hda_intel
    snd_seq_dummy 4868 0
    snd_seq_oss 35584 0
    snd_seq_midi 9376 0
    snd_rawmidi 25760 1 snd_seq_midi
    snd_seq_midi_event 8320 2 snd_seq_oss,snd_seq_midi
    snd_seq 54224 6 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_seq_midi_event
    snd_timer 24836 2 snd_pcm,snd_seq
    snd_seq_device 9612 5 snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_rawmidi,snd_seq
    snd 56996 18 saa7134_alsa,snd_hda_intel,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_hwdep,snd_seq_dummy,snd_seq_oss,snd_rawmidi,snd_seq,snd_timer,snd_seq_device
    soundcore 8800 1 snd

    and doing this:
    cat /dev/urandom > /dev/dsp

    I get noise on speakers (as it should be)

    Please advise me what to do

    Best Regards

    Posted July 30, 2008 at 12:08 am | Permalink
  10. Shahi

    Your blog is good but can you tell me how will scan tv channels using mplayer………????????
    There is one option i.e -tvscan autostart in mplayer but it read all frquencies which have not signals……..

    Posted September 10, 2008 at 5:43 pm | Permalink
  11. krishna

    Hi Prashant,

    I could successfully install Myth TV with the same card. I have Ubuntu Hardy Heron OS. And it works great. I am not able to configure the remote at the moment, though.
    Thanks for suggesting the card.

    Cheers,
    Krishna

    Posted September 30, 2008 at 11:05 pm | Permalink
  12. I can too confirm that MythTV works with this driver and my Pinnacle PCTV 50i ! Thanks for this guide really great help!

    Posted November 6, 2008 at 2:36 am | Permalink
  13. seb

    Great post! Thanks for your hint about using sox!!!
    Up till now I was using TVtime with sound redirection via ‘arecord -D hw:1,0 | aplay’ resulting in the sound lagging behind.
    ‘sox -c 2 -s -r 32000 -t oss /dev/dsp1 -t oss -r 32000 /dev/dsp’ does the job! No sound lag! Thanks a million!

    Running Fedora 10 with
    Haupppauge WinTV HVR 900 USB

    Greetings, Seb.

    Posted December 11, 2008 at 2:09 am | Permalink
  14. seiyachan

    I am able to get audio working in mplayer using the following command line:

    mplayer tv:// -tv driver=v4l2:input=0:norm=pal:width=640:height=480:device=/dev/video0:\
    freq=775.25:alsa:adevice=hw.1,0:amode=1:audiorate=32000:forceaudio:volume=100

    Posted May 2, 2009 at 6:23 pm | Permalink
  15. seiyachan

    the exact command i run is as follow, it works for my laptop:

    mplayer tv://$channel -tv driver=v4l2:device=/dev/video0:chanlist=australia:channel=10:channels=2-ABC,7-Seven,9-Nine,10-Ten,28-SBS:alsa:adevice=hw.1,0:amode=1:audiorate=32000:forceaudio:volume=100:immediatemode=0:norm=PAL:tdevice=/dev/vbi0:tformat=1:tpage=801

    Posted May 2, 2009 at 6:34 pm | Permalink
  16. RAJNISH MISHRA

    hi……….
    i have zenit tv tuner card but how can start in linux…………..i dont know………………..how can start……..rplyyyyyyyyyyyyy

    rajnish mishra

    Posted June 6, 2009 at 11:13 am | Permalink
  17. How is the colors in tvtime ?

    i have installed it in ubuntu, but tvtime shows all channels with most of its colors lost. Mmany channels are displayed in black and white, some display with less color. Do you know how to fix it ?

    Bobys last blog post..Pctv

    Posted June 17, 2009 at 2:29 am | Permalink
  18. When i run sox, i get error

    me@my-desktop:~$ sox -c 2 -s -w -r 32000 -t ossdsp /dev/dsp1 -t ossdsp -w -r 32000 /dev/dsp
    sox: invalid option — w
    sox: SoX v14.2.0

    Failed: invalid option

    Usage summary: [gopts] [[fopts] infile]… [fopts] outfile [effect [effopts]]…

    SPECIAL FILENAMES (infile, outfile):
    - Pipe/redirect input/output (stdin/stdout); use with -t
    -d, –default-device Use the default audio device (where available)
    -n, –null Use the `null’ file handler; e.g. with synth effect
    -p, –sox-pipe Alias for `-t sox -’

    SPECIAL FILENAMES (infile only):
    “|program [options] …” Pipe input from external program (where supported)
    http://server/file Use the given URL as input file (where supported)

    GLOBAL OPTIONS (gopts) (can be specified at any point before the first effect):
    –buffer BYTES Set the size of all processing buffers (default 8192)
    –combine concatenate Concatenate multiple input files (default for sox, rec)
    –combine sequence Sequence multiple input files (default for play)
    –effects-file FILENAME File containing effects and options
    -h, –help Display version number and usage information
    –help-effect NAME Show usage of effect NAME, or NAME=all for all
    –help-format NAME Show info on format NAME, or NAME=all for all
    –input-buffer BYTES Override the input buffer size (default: as –buffer)
    –interactive Prompt to overwrite output file
    -m, –combine mix Mix multiple input files (instead of concatenating)
    -M, –combine merge Merge multiple input files (instead of concatenating)
    –plot gnuplot|octave Generate script to plot response of filter effect
    -q, –no-show-progress Run in quiet mode; opposite of -S
    –replay-gain track|album|off Default: off (sox, rec), track (play)
    -R Use default random numbers (same on each run of SoX)
    -S, –show-progress Display progress while processing audio data
    –version Display version number of SoX and exit
    -V[LEVEL] Increment or set verbosity level (default 2); levels:
    1: failure messages
    2: warnings
    3: details of processing
    4-6: increasing levels of debug messages
    FORMAT OPTIONS (fopts):
    Input file format options need only be supplied for files that are headerless.
    Output files will have the same format as the input file where possible and not
    overriden by any of various means including providing output format options.

    -v|–volume FACTOR Input file volume adjustment factor (real number)
    -t|–type FILETYPE File type of audio
    -s/-u/-f/-U/-A/-i/-a/-g Encoding type=signed-integer/unsigned-integer/floating-
    point/mu-law/a-law/ima-adpcm/ms-adpcm/gsm-full-rate
    -e|–encoding ENCODING Set encoding (ENCODING in above list)
    -b|–bits BITS Encoded sample size in bits
    -1/-2/-3/-4/-8 Encoded sample size in bytes
    -N|–reverse-nibbles Encoded nibble-order
    -X|–reverse-bits Encoded bit-order
    –endian little|big|swap Encoded byte-order; swap means opposite to default
    -L/-B/-x Short options for the above
    -c|–channels CHANNELS Number of channels of audio data; e.g. 2 = stereo
    -r|–rate RATE Sample rate of audio
    -C|–compression FACTOR Compression factor for output format
    –add-comment TEXT Append output file comment
    –comment TEXT Specify comment text for the output file
    –comment-file FILENAME File containing comment text for the output file

    AUDIO FILE FORMATS: 8svx aif aifc aiff aiffc al amb au avr caf cdda cdr cvs cvsd dat dvms f4 f8 fap flac fssd gsm hcom htk ima ircam la lpc lpc10 lu mat mat4 mat5 maud nist ogg paf prc pvf raw s1 s2 s3 s4 sb sd2 sds sf sl smp snd sndfile sndr sndt sou sox sph sw txw u1 u2 u3 u4 ub ul uw vms voc vorbis vox w64 wav wavpcm wv wve xa xi
    PLAYLIST FORMATS: m3u pls
    AUDIO DEVICE DRIVERS: alsa

    EFFECTS: allpass band bandpass bandreject bass bend chorus compand contrast dcshift deemph delay dither earwax echo echos equalizer fade filter flanger gain highpass ladspa loudness lowpass mcompand mixer noiseprof noisered norm oops pad phaser pitch rate remix repeat reverb reverse riaa silence spectrogram speed splice stat stretch swap synth tempo treble tremolo trim vol

    EFFECT OPTIONS (effopts): effect dependent; see –help-effect
    me@my-desktop:~$

    Annies last blog post..THIS SCRIPT IS NO LONGER SERVING DATA. UPDATE YOUR PLUGIN

    Posted July 16, 2009 at 3:19 am | Permalink
  19. Luis

    Hi Annie
    Try replacing
    sox -c 2 -s -w -r 32000 -t ossdsp /dev/dsp1 -t ossdsp -w -r 32000 /dev/dsp

    with
    sox -c 2 -s -2 -r 32000 -t ossdsp /dev/dsp1 -t ossdsp -2 -r 32000 /dev/dsp

    Hope it helps.

    Posted July 26, 2009 at 9:36 am | Permalink
  20. I done that, got following error

    me@me-desktop:~$ sox -c 2 -s -2 -r 32000 -t ossdsp /dev/dsp1 -t ossdsp -2 -r 32000 /dev/dsp
    sox formats: no handler for given file type `ossdsp’
    me@me-desktop:~$

    Posted July 26, 2009 at 3:48 pm | Permalink
  21. Luis

    Hi Annie, install libsox-fmt-oss

    sudo apt-get install libsox-fmt-oss

    Posted July 26, 2009 at 10:27 pm | Permalink
  22. Thanks Luis for the reply, i installed libsox-fmt-oss

    Now i get following error

    me@me-desktop:~$ sox -c 2 -s -2 -r 32000 -t ossdsp /dev/dsp1 -t ossdsp -2 -r 32000 /dev/dsp
    sox formats: can’t open input file `/dev/dsp1′: No such file or directory
    me@me-desktop:~$

    Any idea how to fix the error ?

    Posted July 27, 2009 at 3:18 am | Permalink
  23. Luis

    Hi Annie, maybe you are missing the saa7134_alsa module, try this:

    sudo modprobe saa7134_alsa

    Posted July 27, 2009 at 4:50 am | Permalink
  24. Hi Luis, “sudo modprobe saa7134_alsa” do not five any output.

    Posted July 27, 2009 at 7:21 pm | Permalink
  25. Here is what i get

    me@me-desktop:~$ sudo modprobe saa7134_alsa
    [sudo] password for me:
    me@me-desktop:~$ sox -c 2 -s -2 -r 32000 -t ossdsp /dev/dsp1 -t ossdsp -2 -r 32000 /dev/dsp
    sox formats: can’t open input file `/dev/dsp1′: No such file or directory
    me@me-desktop:~$

    Posted July 27, 2009 at 7:54 pm | Permalink
  26. Luis

    Have you checked if the module is loaded?

    lsmod | grep saa7134

    Posted July 28, 2009 at 10:00 am | Permalink
  27. The module is not loaded.

    me@me-desktop:~$ sudo -s
    [sudo] password for me:
    root@me-desktop:~# lsmod | grep saa7134
    root@me-desktop:~# insmod saa7134
    insmod: can’t read ‘saa7134′: No such file or directory
    root@me-desktop:~#

    How do i load it ?

    Posted July 29, 2009 at 4:06 am | Permalink
  28. Luis

    Try modprobe

    sudo modprobe saa7134
    sudo modprobe saa7134_alsa

    Posted July 31, 2009 at 9:59 am | Permalink
  29. Thanks Luis, now i got the modules loaded, still /dev/dsp1 missing

    me@me-desktop:~$ sudo modprobe saa7134
    [sudo] password for me:
    me@me-desktop:~$ sudo modprobe saa7134_alsa
    me@me-desktop:~$ lsmod | grep saa7134
    saa7134_alsa 20000 0
    saa7134 152020 1 saa7134_alsa
    snd_pcm 82948 3 saa7134_alsa,snd_hda_intel,snd_pcm_oss
    videodev 41600 3 saa7134,tuner,bttv
    ir_common 52228 2 saa7134,bttv
    compat_ioctl32 9344 2 saa7134,bttv
    v4l2_common 20992 3 saa7134,tuner,bttv
    videobuf_dma_sg 20484 3 saa7134_alsa,saa7134,bttv
    videobuf_core 26500 3 saa7134,bttv,videobuf_dma_sg
    snd 62628 16 saa7134_alsa,snd_hda_intel,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_seq_oss,snd_rawmidi,snd_seq,snd_timer,snd_seq_device
    tveeprom 20100 2 saa7134,bttv
    me@me-desktop:~$ sox -c 2 -s -2 -r 32000 -t ossdsp /dev/dsp1 -t ossdsp -2 -r 32000 /dev/dsp
    sox formats: can’t open input file `/dev/dsp1′: No such file or directory
    me@me-desktop:~$ sudo -s
    root@me-desktop:~# sox -c 2 -s -2 -r 32000 -t ossdsp /dev/dsp1 -t ossdsp -2 -r 32000 /dev/dsp
    sox formats: can’t open input file `/dev/dsp1′: No such file or directory
    root@me-desktop:~# ls -l /dev/|grep dsp
    crw-rw—-+ 1 root audio 14, 3 2009-07-31 18:33 dsp
    root@me-desktop:~#

    Posted July 31, 2009 at 6:33 pm | Permalink
  30. hendri

    thanks guys! finaly, my sound work on Gadmei UTV 330+. this blog is guide me to understand about install hardware on linux properly…

    Posted October 18, 2009 at 7:47 pm | Permalink
  31. isidora

    I have instaled tvtime, and it works for my tv card just fine. the only problem i have is with sound :( it doest produce any sound. did i do something wrong? is there any adjustment i need to do to make it work?
    please help. thank you in advance :)

    Posted November 19, 2009 at 7:34 pm | Permalink