HOWTO: watch TV with mplayer

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
doopdoop

HOWTO: watch TV with mplayer

#1 Post by doopdoop »

This is a quick and dirty way to watch TV on an analog TV Card based on the Brooktree chipset (like Hauppauge Win TV or else). I will try to be as newbie friendly as possibly.

We need:
1. the MPlayer DotPup
2. the complete kernel modules ftp://ftp.ibiblio.org/pub/linux/distrib ... ete.tar.gz
3. A compatible TV card

a) Install Mplayer, if you haven't done it yet
b) Download the kernel modules to your /root directory
c) Extract the kernel-modules

Code: Select all

# cd 
# tar zxvf /root/modules-2.4.29-complete.tar.gz 
d) copy the modules in the right location and register them

Code: Select all

# cp -r /root/modules-2.4.29-complete/kernel/drivers/* /lib/modules/2.4
# depmod -a
if you use a non-writable boot medium, you need to repeat this step every time you reboot, so you can put these lines into /etc/rc.d/rc.local. (without the # at the begin).
Alternatively, you could remaster a new copy of puppy.
e) Load the driver for the TV card and the tuner

Code: Select all

# modprobe tuner
# modprobe bttv
This needs to be repeated every time you boot. So, put these commands into /etc/rc.d/rc.local (also without #)
f) Check your sucess by looking at the kernel messages

Code: Select all

# dmesg
You should see something like this at the bottom
{code]
bttv: Bt8xx card found (1).
bttv0: Bt878 (rev 17) at 00:11.0, irq: 10, latency: 32, mmio: 0xdf113000
bttv0: detected: Hauppauge WinTV [card=10], PCI subsystem ID is 0070:13eb
bttv0: using: Hauppauge (bt878) [card=10,autodetected]
bttv0: Hauppauge/Voodoo msp34xx: reset line init [5]
[/code]

g) Lets create a TV watching script

Code: Select all

#!/bin/sh
mplayer -tv driver=v4l:device=/dev/video0:width=320:height=240:norm=pal:chanlist=europe-west tv://
Adapt the settings to your local conditions, e.g. norm=ntsc or chanlist=us-cable. See Mplayer docs (http://www.mplayerhq.hu) for more on this.
Save this script to /usr/local/bin/watchtv and make it executable

Code: Select all

# chmod 755 /usr/local/bin/watchtv
h) Try it.

Code: Select all

# watchtv
Cross your fingers and hope to see window, maybe with a real channel already. Use the keys h and k to switch channels, f for fullscreen and q for quit. If you are lucky, you can control the volume with the keys 0 and 9, otherwise use mixer.tcl
i) (Optionally) You can add an channels option to your watchtv script to define which channels are really used and give them names. See mplayer docs.

User avatar
Bancobusto
Posts: 168
Joined: Mon 13 Jun 2005, 20:52
Location: Vancouver Island

#2 Post by Bancobusto »

Thanks alot fot that :D

Not having a TV card, I never really even wondered what the steps would be. Now I have a pretty good idea!

Good work doopdoop!

:lol:
Freedom isn't just a Puppy-Linux forum member!

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#3 Post by Flash »

Yes, thanks. I have a Hauppauge TV tuner card but I never thought I'd be using it to watch TV in Puppy. Now I might just give it a shot - when I can find the time.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#4 Post by GuestToo »

screenshot: http://tinypic.com/9ga99e.jpg

the drivers for my tv card are about 95k

i made a rox appdir that copies the drivers to /lib/modules and depmod's then runs mplayer

so the drivers are only loaded if the tv program is run (and only the first time the tv program is run)

doopdoop

#5 Post by doopdoop »

Actually, you do need only a small portion of the drivers, namely the ones in media/video and i2c, and you dont even need all of them. It should be about 200k or even less. I have seen that GuestToo has xawtv on the todo-list, so these kernel-modules are a candidate for the next release, don't you think ?

don largo
Posts: 18
Joined: Sat 10 Feb 2007, 10:13

puppy with TV

#6 Post by don largo »

Hello doopdoop, et al. I didn't want to have to ask really stupid questions, but after days of wasting time, I am left with no alternative.

I have an installation of puppy 2.14. I have a winfast 2000xp tv tuner card. Apparently I have a driver--video for linux, right? I have Gxine, Mplayer, and VLC. Mplayer responds to the following command from command line or file:

sh-3.00# mplayer -tv driver=v4l:device=/dev/video0:width=640:height=480:norm=ntsc:chanlist=japan-b.cast tv//

with:

MPlayer 1.0rc1-3.4.4 (C) 2000-2006 MPlayer Team
CPU: AMD Athlon(tm) MP 1800+ (Family: 6, Model: 6, Stepping: 2)
3DNow supported but disabled
3DNowExt supported but disabled
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 0
Compiled for x86 CPU with extensions: MMX MMX2 SSE
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing tv//.
File not found: 'tv//'
Failed to open tv//.


Exiting... (End of file)
sh-3.00#

dmesg seems to indicate that the card is ready to play (correct me if I am wrong):

Linux agpgart interface v0.101 (c) Dave Jones
agpgart: Detected VIA KT400/KT400A/KT600 chipset
agpgart: AGP aperture is 64M @ 0xe0000000
cdrom: hdc: mrw address space DMA selected
ISO 9660 Extensions: RRIP_1991A
Linux video capture interface: v2.00
bttv: driver version 0.9.16 loaded
bttv: using 8 buffers with 2080k (520 pages) each for capture
bttv: Bt8xx card found (0).
PCI: Found IRQ 11 for device 0000:00:09.0
PCI: Sharing IRQ 11 with 0000:00:09.1
PCI: Sharing IRQ 11 with 0000:00:0f.0
PCI: Sharing IRQ 11 with 0000:00:10.3
PCI: Sharing IRQ 11 with 0000:00:10.2
bttv0: Bt878 (rev 17) at 0000:00:09.0, irq: 11, latency: 32, mmio: 0xdfdfe000
bttv0: detected: Leadtek WinFast TV 2000 [card=34], PCI subsystem ID is 107d:6606
bttv0: using: Leadtek WinFast 2000/ WinFast 2000 XP [card=34,autodetected]
bttv0: gpio: en=00000000, out=00000000 in=00bf7707 [init]
bttv0: using tuner=5
bttv0: i2c: checking for MSP34xx @ 0x80... not found
bttv0: i2c: checking for TDA9875 @ 0xb0... not found
bttv0: i2c: checking for TDA7432 @ 0x8a... not found
bttv0: i2c: checking for TDA9887 @ 0x86... not found


Gxine and VLC apparently see that there is a card and driver, but I cannot, for the life of me, see how the use of the tuner function is invoked from any of these programs. Am I an imbecile, or are many of you being intentionally vague? To be direct. What software is to be used for viewing television via a tuner card and is there any way to avoid three weeks of intense study in order to launch said software?

While I am not adept at linux or anything else, I have dabbled in computers from an early age. My only unix experience is from having had an old-fashioned unix shell account from which I was able to minimally navigate and invoke available programs. Does this disqualify me from puppydom or are we allowed to progress from infancy to relative competence?

While I am on a roll: I have looked over many linux books and all fall into two distinct categories. There are the linux for dummies genre which go on and on about generalities without end or significance; and there are the linux for smart guys who know a lot about command lines and virtually nothing of the English language genre. Is there any material which might include useful information for a linux beginner and which is written in the English language?

Thank you for your patience and understanding. Thank you for any leads/references.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#7 Post by GuestToo »

mplayer -tv driver=v4l:device=/dev/video0:width=640:height=480:norm=ntsc:chanlist=japan-b.cast tv://

is all on one line ... there is a space between chanlist=japan-b.cast and tv:// ... note: it is tv:// not tv//

keys:
h, k - change channels
f - full screen
q - quit

hogar
Posts: 17
Joined: Wed 14 Feb 2007, 11:29

#8 Post by hogar »

Hello!
I´m new to Linux.
I followed your instruction on how to watch TV with Mplayer. The picture is O.K., but I´m geting no sound.

I used this command:

sh-3.00# mplayer -tv driver=v4l2:device=/dev/video0:width=640:height=480:norm=pal:chanlist=europe-west tv://

and this is the report:

MPlayer 1.0rc1-3.4.4 (C) 2000-2006 MPlayer Team
CPU: Intel Celeron 2/Pentium III Coppermine,Geyserville (Family: 6, Model: 8, Stepping: 10)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 0
Compiled for x86 CPU with extensions: MMX MMX2 SSE
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing tv://.
Cache fill: 0.00% (0 bytes)
TV file format detected.
Selected driver: v4l2
name: Video 4 Linux 2 input
author: Martin Olschewski <olschewski@zpr.uni-koeln.de>
comment: first try, more to come ;-)
Selected device: LifeView FlyTV Platinum FM / Go
Tuner cap: STEREO LANG1 LANG2
Tuner rxs: MONO
Capabilites: video capture video overlay VBI capture device tuner read/write streaming
supported norms: 0 = PAL; 1 = PAL-BG; 2 = PAL-I; 3 = PAL-DK; 4 = NTSC; 5 = SECAM; 6 = PAL-M; 7 = PAL-Nc; 8 = PAL-60;
inputs: 0 = Television; 1 = Composite1; 2 = Composite2; 3 = S-Video;
Current input: 0
Current format: BGR24
v4l2: current audio mode is : MONO
==========================================================================
Opening video decoder: [raw] RAW Uncompressed Video
VDec: vo config request - 640 x 480 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
VO: [xv] 640x480 => 640x480 Planar YV12
Selected video codec: [rawyv12] vfm: raw (RAW YV12)
==========================================================================
Audio: no sound
Starting playback...

After that I can see the picture, but hear no sound.

Can you please help me.
Thank you.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#9 Post by GuestToo »

you can plug the audio out jack on your tv card into the line in jack on your audio card ... adjust the volume of the line in jack with the mixer ... some tv cards work this way

i think your card can send audio directly over the pci bus ... you need to add mplayer options something like this:

for the oss driver:
immediatemode=0:adevice=/dev/dsp1:amode=1

for the alsa driver:
immediatemode=0:alsa:adevice=hw.1,0:audiorate=32000:amode=1

you may need to add something like:
forceaudio:volume=100

http://www.linuxtv.org/v4lwiki/
http://www.linuxtv.org/v4lwiki/index.php/Saa7134-alsa
http://www.linuxtv.org/v4lwiki/index.ph ... ntable=yes
http://www.linuxtv.org/v4lwiki/index.ph ... 0TV_mobile
http://www.google.ca/search?num=100&q=m ... sa+adevice

hogar
Posts: 17
Joined: Wed 14 Feb 2007, 11:29

#10 Post by hogar »

Thank you for your advice,
I pluged the audio out jack on tv card into the line in jack on audio card and now I can hear the sound.

Thank you again!

don largo
Posts: 18
Joined: Sat 10 Feb 2007, 10:13

#11 Post by don largo »

Thanks you guys. I also found a couple of other little syntax issues while correcting the colon after tv. "chanlist=japan-b.cast" is actually "bcast" and so on. Everything works perfectly now.

I wish somebody had taken me up on the other issue of trying to understand the linux environment. To be specific to mplayer, for example, where can I learn the mplayer command line? Surely you all didn't just suss it out by trial and error?

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#12 Post by GuestToo »


don largo
Posts: 18
Joined: Sat 10 Feb 2007, 10:13

#13 Post by don largo »

Thanks all. I got mplayer to run as per doopdoop and with corrected syntax. Creating an icon on the desktop gives me easy access.

Also, I went to the mplayer homepage to try to understand the command line better. My understanding from that page was that I could manipulate/override keybindings through a configuration file "-input.conf" At the path: /root/.mplayer I found the files. The exact wording from mplayerhq is:

MPlayer allows you bind any key/button to any Mplayer command using a simple config file. The syntax consist of a key name followed by a command. The default config file location is $HOME/.mplayer/input.conf but it can be overridden using the -input conf option (relative path are relative to $HOME/.mplayer).

config
gui.conf
gui.history
gui.pl
gui.url

Not having found the file "/.mplayer/input.conf" as referenced at www.mplayerhq.hu, I tried creating the -input.conf referenced there along with the sample script, but to no avail. any hints on how to keybind to mplayer?

Next question. How do I specify which channels to tune within my chanlist=japan-bcast tv? I googled and found "channels=[chan1],[chan2]" but I can't seem to get this to work in any one of a thousand ways in which I have tried to appease the mplayer syntax troll. Any hints?

Any/all replies are greatly appreciated.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#14 Post by GuestToo »

i put these lines in /root/.mplayer/input.conf:

MOUSE_BTN0 tv_step_channel 1
MOUSE_BTN2 tv_step_channel -1
MOUSE_BTN3 tv_step_channel 1
MOUSE_BTN4 tv_step_channel -1

left click goes down 1 channel, right click goes up one channel

rolling the mouse wheel changes channels

because i didn't want to interfere with using the mouse wheel to seek in a movie, i created a file called /root/.mplayer/inputtv.conf with that configuration, and another file configured for movies called /root/.mplayer/input00.conf, and i start mplayer to watch tv something like this:

cp -f /root/.mplayer/inputtv.conf /root/.mplayer/input.conf
mplayer -tv driver=v4l:device=/dev/video0: ...
cp -f /root/.mplayer/input00.conf /root/.mplayer/input.conf

i don't know why, but each movement of my mouse wheel is like 2 clicks of a mouse button, so it changes 2 channels at a time ... i worked around the problem by duplicating the channel numbers ... single channel numbers might look like this:

channels=3-3,4-4,5-5,11-11 ...

i duplicated the channels like this:

channels=3-3,3-3,4-4,4-4,5-5,5-5,11-11,11-11 ...

my mplayer command looks something like this:

mplayer -tv driver=v4l:\
device=/dev/video0:width=640:height=480:norm=ntsc:chanlist=us-cable:\
channels=3-3,4-4,5-5,11-11,13-13,14-14,18-18,20-20,21-21,22-22,\
43-43,44-44,45-45,46-46,48-48,49-49,58-58 \
tv://11

you could do something like this:

channels=3-cbs, ... or channels=cbs-3, ... i don't remember whether it's channel-id or id-channel

also, for my card there is a cable between the sound output jack on the tv card and the line in card of my sound card, so i set the volume of the line jack like this:

setvol 6 92 92
mplayer -tv driver=v4l: ...
setvol 6 0 0

don largo
Posts: 18
Joined: Sat 10 Feb 2007, 10:13

#15 Post by don largo »

GuestToo, you've been a really big help.

I hadn't even considered using the mouse--that's an interesting idea. What I'm wanting to do is utilize a wireless keyboard which has some extra buttons above the F-keys which don't seem to do anything in puppy so far. I thought that I could use some of them to control video and tv and relieve my linux skeptic wife from having to learn this thing through me while I don't understand it all that well. Talk about the halt leading the blind.

At the same time, I see no reason to have fifty channels with nothing to tune into except static. For this reason I wanted to limit the programmed channel list to the eight or so channels available to me. From you example, I can easily see where I got into syntax trouble--again.

The info you've provided is more than sufficient to get me on track--I hope so, at least.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#16 Post by GuestToo »

i think there's a xawtv package available somewhere ... i haven't tried it ... i did install xawtv on an older version of Puppy once, but it had problems changing channels (it would sometimes stick and crash)

you can see if the extra keys do anything by typing xev in an rxvt console ... press the keys and see if they do anything ... if they do, note the numbers belonging to those keys, then you can type xmodmap -pke to see if those numbers are set to anything ... you can set keycodes for those keys using xmodmap, for example, you could put something like this in /root/.Xmodmap:

keycode 229 = XF86Search
keycode 120 = XF86Mail
keycode 194 = XF86WWW

and then configure mplayer to respond to those keys

Post Reply