Archive for the ‘tv mplayer mencoder script bash hack’ Tag

rectv

Here is a nice script I wrote, which I figured I’d share with the world – it’s for doing TV related stuff with just mplayer/mencoder rather than needing a special program (It could probably be done inside cron too):

#!/bin/bash

mencoder tv://$1 -tv driver=v4l2:norm=PAL:quality=100:input=0 -of avi -ovc lavc -oac mp3lame -lavcopts vbitrate=10000 -o tv.`date +%S%M%H%d%m%y`.avi -ffourcc DX50

Nice, eh? This records the channel specified on the command-line on my tuner, which in my case is always 60 since that’s where sky is plugged in. It captures (not sure which codec it encodes with, probably some variety of mpeg4) to a file named from the current date and time to the current directory.

One thing I want to do is add an option so I can specify which sky channel it’s recording on the command line, and it’ll look up TV listings on the net and name the file after the program name. Heck, maybe even give it a beamer and let it control the sky box.

Any idea how exactly to get it to encode properly so my files aren’t massive and will play in a sane media player, please tell me.  I suck at mencoder options.

Edit: I’ve recently figured out some encoding with lavc and mpeg4. The quality seems rather nice, and the file size isn’t /too/ massive. Also I figured out nice deinterlacing. Here is the updated script

mencoder tv://$1 -tv driver=v4l2:norm=PAL:quality=60:input=0 -of avi -ovc lavc -oac lavc -lavcopts vqscale=5 -o tv.`date +%S%M%H%d%m%y`.avi

And to play the videos with deinglacing I use:

mplayer -vf lavcdeint tv.<dateandtime>.avi

You can modify the original command to let you watch TV with mplayer too (can’t figure out deinterlacing with this one, lavcdeint only works when playing video, not live TV):

mplayer -tv driver=v4l2:norm=PAL:quality=60:input=0 tv://$1
Follow

Get every new post delivered to your Inbox.