Watch TV with Linux
From LinuxIntro
Here is how you can watch TV on your Linux desktop using a USB TV controller.
Contents |
[edit] Hauppauge PVR USB 2
This description works with a Hauppauge PVR USB 2, a TV Tuner that you attach via USB to your computer. It uses Mike Isely's driver pvrusb2. It may work same or similar for other TV tuners, but we did not test it. We tested it with SUSE Linux 11 and 11.1. Other distributions will probably work same or similar.
[edit] Get it work
[edit] Get a video device
- connect your TV Tuner via USB to your computer and to the electric power supply. Verify you did it right:
# hwinfo --usb --short
[...]
tv card:
Hauppauge WinTV
[...]
- get the firmware
mkdir -p /lib/firmware/ cd /lib/firmware wget http://dl.ivtvdriver.org/ivtv/firmware/ivtv-firmware.tar.gz tar xvzf ivtv-firmware.tar.gz
- verify you have the driver
modprobe -l | grep pvr /lib/modules/2.6.25.11-0.1-default/kernel/drivers/media/video/pvrusb2/pvrusb2.ko
- load the driver
modprobe pvrusb2
- make sure the driver has loaded
dmesg usbcore: registered new interface driver pvrusb2 drivers/media/video/pvrusb2/pvrusb2-main.c: Hauppauge WinTV-PVR-USB2 MPEG2 Encoder/Tuner : V4L in-tree version drivers/media/video/pvrusb2/pvrusb2-main.c: Debug mask is 31 (0x1f) pvrusb2: Device microcontroller firmware (re)loaded; it should now reset and reconnect. usb 2-4: USB disconnect, address 4 pvrusb2: Device being rendered inoperable usb 2-4: new high speed USB device using ehci_hcd and address 5 usb 2-4: configuration #1 chosen from 1 choice usb 2-4: New USB device found, idVendor=2040, idProduct=2400 usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 usb 2-4: Product: WinTV usb 2-4: Manufacturer: Hauppauge usb 2-4: SerialNumber: 2401-00-0082BA22 usb 2-4: reset high speed USB device using ehci_hcd and address 5 cx25840' 4-0044: cx25843-24 found @ 0x88 (pvrusb2_a) tuner' 4-0043: chip found @ 0x86 (pvrusb2_a) tda9887 4-0043: tda988[5/6/7] found tuner' 4-0061: chip found @ 0xc2 (pvrusb2_a) wm8775' 4-001b: chip found @ 0x36 (pvrusb2_a) tveeprom 4-00a2: Hauppauge model 24019, rev C389, serial# 8567330 tveeprom 4-00a2: tuner model is TCL MFPE05 2 (idx 89, type 38) tveeprom 4-00a2: TV standards PAL(B/G) PAL(I) SECAM(L/L') PAL(D/D1/K) (eeprom 0x74) tveeprom 4-00a2: audio processor is CX25843 (idx 37) tveeprom 4-00a2: decoder processor is CX25843 (idx 30) tveeprom 4-00a2: has radio, has IR receiver, has no IR transmitter pvrusb2: Supported video standard(s) reported available in hardware: PAL-B/B1/D/D1/G/H/I/K;SECAM-B/D/G/H/K/K pvrusb2: Mapping standards mask=0xff00ff (PAL-B/B1/D/D1/G/H/I/K;SECAM-B/D/G/H/K/K1/L/LC) pvrusb2: Setting up 20 unique standard(s) pvrusb2: Set up standard idx=0 name=PAL-B/G pvrusb2: Set up standard idx=1 name=PAL-D/K pvrusb2: Set up standard idx=2 name=SECAM-B/G pvrusb2: Set up standard idx=3 name=SECAM-D/K pvrusb2: Set up standard idx=4 name=PAL-B pvrusb2: Set up standard idx=5 name=PAL-B1 pvrusb2: Set up standard idx=6 name=PAL-G pvrusb2: Set up standard idx=7 name=PAL-H pvrusb2: Set up standard idx=8 name=PAL-I pvrusb2: Set up standard idx=9 name=PAL-D pvrusb2: Set up standard idx=10 name=PAL-D1 pvrusb2: Set up standard idx=11 name=PAL-K pvrusb2: Set up standard idx=12 name=SECAM-B pvrusb2: Set up standard idx=13 name=SECAM-D pvrusb2: Set up standard idx=14 name=SECAM-G pvrusb2: Set up standard idx=15 name=SECAM-H pvrusb2: Set up standard idx=16 name=SECAM-K pvrusb2: Set up standard idx=17 name=SECAM-K1 pvrusb2: Set up standard idx=18 name=SECAM-L pvrusb2: Set up standard idx=19 name=SECAM-LC pvrusb2: Initial video standard auto-selected to PAL-B/G pvrusb2: Device initialization completed successfully.
- make sure an additional video device exists
ls /dev/video* /dev/video /dev/video0
[edit] Watch TV
According to http://www.isely.net/pvrusb2/usage.html#V4L, your watching application needs to be capable of decoding an mpeg2 stream.
- watch that you see a video signal
gqcam /dev/video
You will not be able to switch channels, and it is not sure you see more than snow. How to go on, depends on your distribution:
[edit] SUSE Linux 11 and 11.1
- make sure you have one (and not more) soundcard and it works.
- make sure the videolan (VLC) repository is contained in your yast installation repositories:
yast2 -> Software -> Software Repositories -> Community Repositories -> Videolan
- Install several development packages
yast -i libmpeg2-devel yast -i zvbi-devel yast -i arts-devel yast -i kdelibs3-arts yast -i kdemultimedia3-arts-mad yast -i libmpg123-arts yast -i openmotif-devel yast -i aalib-devel yast -i libdv-devel yast -i libmad-devel
Download xawtv's latest cvs snapshot from http://dl.bytesex.org/cvs-snapshots/?N=A. In this example, we assume it is xawtv-20081014-100645.tar.gz.
- Unpack the snapshot
tar xvzf xawtv-20081014-100645.tar.gz cd xawtv
- Configure the compile
./autogen.sh ./configure
- build it
make
- install it
make install
- prepare the sender list for xawtv by calling
scantv
You are asked some questions. If you do not know what PAL standard your country uses, consult wikipedia.
- start it
/usr/local/bin/xawtv
[edit] Record a video
To capture a video with sound, do
echo false >/sys/class/pvrusb2/sn-*/ctl_mute/cur_val && cat /dev/video > myvideo.mpg
In this case, we assume /dev/video is the video device that you created above. This command is possible because mpeg2 data is streamed over /dev/video. It contains sound.
[edit] TroubleShooting
[edit] no such file or directory
[edit] Symptom
open(/dev/dsp): No such file or directory ALSA lib pcm_hw.c:1240:(_snd_pcm_hw_open) Invalid value for card alsa: open plughw: No such file or directory open(/dev/dsp): No such file or directory
[edit] Solution
Remove every soundcard but one, re-configure sound using yast2 sound, restart sound system using /etc/init.d/alsasound restart
[edit] Invalid value for card
[edit] Symptom
ALSA lib pcm_hw.c:1240:(_snd_pcm_hw_open) Invalid value for card alsa: open plughw: No such file or directory
[edit] Solution
Remove every soundcard but one, re-configure sound using yast2 sound, restart sound system using /etc/init.d/alsasound restart
[edit] There is no sound
[edit] Symptom 1
You have several soundcards. Your speakers are attached to /dev/dsp, but nevertheless, there is no sound.
[edit] Reason 1
The reason is partly unclear. It seems that xawtv does not in all cases send sound output to /dev/dsp, it seems to enumberate the sound cards differently.
[edit] Solution 1
Remove every soundcard but one, re-configure sound using yast2 sound, restart sound system using /etc/init.d/alsasound restart
[edit] Symptom 2
When starting xawtv, you get an error message "can't play audio stream". Then there is no audio to be heard.
[edit] Reason 2
Another application is blocking your soundcard.
[edit] Solution 2
Use lsof to find out what application is blocking your soundcard. Quit it:
lsof | grep /dev/dsp
[edit] module: pvrusb2 not found
[edit] Symptom
When loading the module you get the error msg:
FATAL: Module pvrusb2 not found.
[edit] Reason
The module loader needs to understand the dependencies first
[edit] Solution
depmod -a
[edit] More information
- ~/.tv contains config files for xawtv4
- good irc channels for your needs are on freenode: #v4l, #pvrusb2 and #mythtv-users
- switch frequency like this:
echo "182270001" > /sys/class/pvrusb2/sn-8567330/ctl_frequency/cur_val
[edit] Switch on hr
echo "55250000" > /sys/class/pvrusb2/sn-8567330/ctl_frequency/cur_val

