My Linux PVR|
These are some notes on how I've setup my own Linux PVR system.
HardwareI use a simple Celeron 2ghz system with 196mb of ram. I don't think it needs that much ram. I also have a Flyvideo 98 TV card. Picture quality is really so ... so. There are always vertical inference lines, but its not too awful.
It runs a somewhat bastardised version of Slackware 8.1.
Seting up the tv cardYou of course need a bunch of extra modules for the TV card to work. The BTTV stuff in the modern kernels (I use 2.4.20) seems to be fine. Instead of trying to be smart about how the TV card modules are loaded, I just have this simple script that runs at startup:
/sbin/modprobe videodev /sbin/modprobe bttv card=27 tuner=34 gbuffers=16 fieldnr=1 /sbin/modprobe i2c /sbin/modprobe tvaudio /sbin/modprobe msp3400I think the i2c stuff isn't necessary as it always fails.
Now I've also installed xawtv. That allows me to check the setup and also comes with the invaluable v4lctl command that allows you to change channels from a script. So I do something like this to choose channel 'one':
v4lctl setstation oneNB: v4lctl will look up stations in $HOME/.xawtv. Obviously if you've run xawtv initially and saved your list of stations that should be fine. However, I launch a TV scheduling daemon (like cron) in the startup scripts on my box. Suffice to say $HOME is not set correctly and the v4lctl would fail. So make sure $HOME is set before you run v4lctl.
Recording TVI initially used mencoder (part of mplayer) to record TV. It was generally OK except that the very start of the recording was horribly out of audio sync (perhaps the first 10 to 20secs).
Then I discovered nvrec. This is 'da bomb' as far as I'm concerned. Its actually a collection of commands that use different video encoding libraries. I mainly use divx4rec, which utilises the free divx libraries from www.divx.com. The odd thing though is that last 'proper' release of nvrec only seems to compile against certain older versions of the divx.com linux libraries. The latest one (as at sept 2003) won't work. I had to use a 2002 one. Anyway, once it goes, it goes great. Here's a quick example of how I start a recording:
v4lctl setstation one rexima line rec divx4rec -F $((60*25)) -w 352 -h 288 -norm PAL -input Television \ -ab 96 -vb 800 -o text.avi -s stereo -r 32000 -QThe -F argument takes the number of frames you want to record (so the example above would record 60 seconds at 25 frames per second), -w and -h are the width and height of your video, -ab is the audio bitrate, -vb is the divx video bitrate and the '-s stereo' is to force stereo even though I have a mono TV card. The '-r 32000' is to get around a problem I noticed with playback of divx files created using this technique. I originally recorded without the '-r 32000' and played back the video using mplayer. It always worked fine. It wasn't until someone was trying to playback in windows that there was a problem. Basically, during playback in windows, the sound would be high pitched and fast ... like a chipmunk. What I later discovered is that divx4rec defaults to an audio sampling rate of 44100khz, however my audio card was choosing to use a 32000khz audio sample rate. It seemed that divx4rec would still write into the divx file that it had been recorded at a 44100khz sample rate. Mplayer must have ignored this when playing back and hence the sound was fine. However, Windows players must have chose to playback with a 44100 sample rate and hence played everything back too fast. So the '-r 32000' indicates to actually record with a 32000 sample rate.
NotesJust for reference, here is the mencoder line I used to use:
mencoder -tv on:driver=v4l:input=0:norm=PAL:width=320:height=240: device=/dev/video0:audiorate=32000:forcechan=2:fps=25 \ -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=800 -oac mp3lame \ -lameopts br=96:cbr -vop pp=lb -o test.aviYou can add -endpos to control how long to record for.
I'm now not sure whether the rexima line rec actually does anything. I've since started adding the following to my divx4rec line and it works much much better:
-mixsrc /dev/mixer:line -mixvol /dev/mixer:igain:10
pablo , 2004-08-23 03:51:35