Registrare la TV su Linux

Questi sono appunti dedicati alla registrazione della TV (e alla visualizzazione di quanto registrato) usando Linux e una scheda di acquisizione TV. Al momento sto usando una Hauppage WinTV Express, una scheda molto economica basata sul chip BT878.

Kernel

Il kernel usato e` un 2.6.12. Occorre compilare il modulo "bttv" (aka bt848) che supporta anche il bt878. Al momento non sono riuscito a usare (ammesso che ci sia dentro, perche` ho dei dubbi) l'encoder dell'audio della scheda TV, per cui ho collegato la sua uscita audio all'ingresso della sound blaster e poi registro da quella. Per registrare dal line in della SB occorre settare appropriatamente aumix (c'e` il pacchetto debian di aumix). Anche per vedere la TV in diretta (e quindi ascoltare il line in) occorre settare aumix.

Per vedere la TV

Per vedere e basta la TV (su X e un monitor, non su una TV) uso l'applicazione "tvtime" della quale c'e` il pacchetto Debian. Fra le varie, mi e` sembrata la piu` semplice e funzionale per il mio scopo, che e` guardare il TG in una finestra, senza telecomando o altro.

Per registrare un programma TV

Sto facendo prove con mencoder (programma di codifica che e` parte del pacchetto di mplayer). Dal momento che in Debian Sarge mplayer e mencoder non ci sono, uso i pacchetti non ufficiali che si trovano qui:

# video e audio
deb ftp://ftp.nerim.net/debian-marillat/ sarge main

Mencoder consente di registrare da command line, il che va benissimo per metterlo in cron e registrare i propri programmi mentre si e` fuori (ah, l'ssh!). Al momento sto provando a trovare un compromesso fra qualita` e occupazione di disco.

Questo funziona per registrare dalla TV, pero` non sceglie il canale, quindi registra sull'ultimo canale sul quale era stata sintonizzata la scheda TV. (una riga sola, l'ho spezzata con un backslash)

mencoder tv:// -tv driver=v4l2:width=768:height=576:device=/dev/video0:buffersize=256:fps=25 -ovc lavc \
-lavcopts vcodec=mpeg4:vbitrate=1460:keyint=300 -oac mp3lame  -vop pp=0x20000  -o test2.avi

Poi ci sono comandi piu` esoterici, che sto ancora studiando. Riporto da un altro sito:

How to watch tv with mplayer
First: why would you watch tv with mplayer instead of Xawtv? Well, for me Xawtv doesn't scale to the full screen when I select: full screen. Zapping (another tv app) does it better, but still, the tv quality is not too nice. In comes mplayer, which allows to do on-the-fly de-interlacing and 3D denoising (meaning: it reduces noise in both spacial directions and on the temporal axis). The command that works best for me is:

mplayer -tv on:driver=v4l:device=/dev/v4l/video1: input=0:channel=27:width=768:height=576:fps=25 -vop lavcdeint,denoise3d=4:3:6

Be sure to put all that on one line (note that I have inserted extra spaces to avoid the lines getting too long; after none of the ":" should there be a space)! Oh, in this case, the tv-tuner is set to channel 27; for watching the signal on the composite video input of the tv-card (video recorder for instance), use:
mplayer -tv on:driver=v4l:device=/dev/v4l/video1:input=1:width=768:height=576:fps=25 -vop lavcdeint,denoise3d=4:3:6
Also, to have audio you have to make sure the mixer control for the input channel of your audio card that you connected the tv-card-audio output with, is set to 70% of maximum volume or so.

How to record tv with mencoder
This was quite tough, since I couldn't manage to get the audio as well. After a lot of messing around I found that selecting the audio input for recording in kmix and alsamixergui was not good enough (beats me why), but aumix does the job. It even does the job on the command line (but you are free to use the GUI and play with the buttons and sliders), so you can just do:
aumix -l R -l 75
Which sets the record channel to the line input of the audio card, and the record volume to 75. Then you should be able to record, which I do with:

mencoder -tv on:driver=v4l:device=/dev/v4l/video1: channel=27:width=768:h eight=576: fps=25 -vop lavcdeint,denoise3d=4:3:6 -oac mp3lame -lameopts abr=:preset=128 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1500 -info name=test:artist=channel-27: genre=trash:subject=snippet:copyright=aRTee: srcform=teevee:comment='just testing' -frames 500 -o videocap.avi

See man mencoder for the right syntax and options (note that I have inserted extra spaces to avoid the lines getting too long; after none of the ":" should there be a space); the -frames 500 equals 20 seconds (25 frames per second) which I just put there for testing. With this bitrate you get 1 hour of video into 770MB or so. Play with the settings to get the right balance; the command I use is just here as an example and startingpoint. Also, this pushes my system to 92 - 98% load, quite high for an Athlon 2400+ (2GHz) CPU.... 

Per rivedere la roba registrata

Su Windows funziona bene Videolan Player (www.videolan.org).

Su Linux funziona bene mplayer (chei l'avrebbe mai detto?)

Per rivedere sul Kiss dp1500

}}}

Command line completa per registrare

Questa e` la command line completa che sto usando per registrare la roba tramite righe di crontab. Contiene i parametri relativi al tempo di registrazione e al cambio di canale. Ovviamente i canali dipendono dalle zone dove si riceve la TV.

mencoder -quiet -endpos 1:00:00 tv:// -tv driver=v4l2:channel=48:width=704:height=576:device=/dev/video0:buffersize=256:fps=25 -ovc xvid -xvidencopts pass=1:turbo:par=pal43 -oac mp3lame -vop pp=0x20000 -o testboh5.avi

Questa e` una breve descrizione dei parametri che vanno modificati: