Leadtek Winfast 2000XP Expert
This page is written for the "Leadtek Winfast 2000XP Expert" card with the audio out connected to the motherboard AUX in, running Ubuntu dapper with ALSA.
Warning: make sure you understand roughly what is going on before using the scripts given below
Watching TV with tvtime
Install tvtime and use the tvtime-scanner command to pick up channels. You might need to check the capture levels and settings on your card (with eg. amixer or alsamixer).
Once tvtime is working and you're happy with volume control you can enable the tvtime module in local_conf.py:
plugin.remove('tv.mplayer')
plugin.activate('tv.tvtime')You may have to edit the keymap when using tvtime which is described here and you will need to setup XMLTV as described here.
An example channel list (for Belgian cable) can be seen here.
Recording with mencoder
The main stumbling block with this card and mencoder is making sure you set the brightness, contrast, hue, saturation levels in VCR_CMD and making sure the video mute is off and the capture is correctly on.
The following settings for local_conf.py are for use with AUX in using Belgium PAL. I haven't tested the commands below as I use the scipts instead (see below).
TV_DRIVER = 'v4l2'
TV_DEVICE = '/dev/video0'
TV_INPUT = 0
TV_REC_SIZE = (768, 576)
AUDIO_DEVICE = 'hw.0,0'
VCR_AUDIO = (':adevice=%s' % AUDIO_DEVICE +
':alsa:audiorate=32000' + # 44100 for better sound
':forceaudio:amode=1')
AMIXER = '/usr/bin/amixer'
V4LCTL = '/usr/bin/v4lctl'
# the following numid's can be obtained by running amixer controls
VCR_PRE_REC = ( AMIXER + '-q cset numid=22 off;' + # mute aux so you don't hear via playback
AMIXER + '-q cset numid=23 90%;' + # set aux vol
AMIXER + '-q cset numid=26 3;' + # set capture to aux
AMIXER + '-q cset numid=27 on;' + # set capture on
AMIXER + '-q cset numid=28 90%;' + # set capture volume
V4LCTL + 'volume mute off' ) # video mute off
VCR_CMD = (CONF.mencoder + ' ' +
'tv:// ' + # New mplayer requires this.
'-tv driver=%s:input=%d' % (TV_DRIVER, TV_INPUT) +
':norm=PAL-BG' + # For Belgium
':channel=%(channel)s' + # Filled in by Freevo
':chanlist=%s' % CONF.chanlist +
':width=%d:height=%d' % (TV_REC_SIZE[0], TV_REC_SIZE[1]) +
':outfmt=%s' % TV_REC_OUTFMT +
':device=%s' % TV_DEVICE +
':brightness=53:contrast=26:saturation=50:hue=50' + # the 'trick'
VCR_AUDIO + # set above
' -ovc lavc -lavcopts ' + # Mencoder lavcodec video codec
'vcodec=mpeg4' + # lavcodec mpeg-4
':vbitrate=3000:' + # Change lower/higher, bitrate
':buffersize=64:' + # 64mb buffer
'keyint=30 ' + # Keyframe every 10 secs, change?
'-oac mp3lame -lameopts ' + # Use Lame for MP3 encoding, must be enabled in mencoder!
'br=128:cbr:mode=3 ' + # MP3 const. bitrate, 128 kbit/s
'-ffourcc divx ' + # Force 'divx' ident, better compat.
'-endpos %(seconds)s ' + # only mencoder uses this so do it here.
'-o %(filename)s') # Filled in by Freevo
VCR_POST_REC = ( AMIXER + '-q cset numid=22 on;' + # unmute aux
V4LCTL + 'volume mute on' ) # video mute on
Passing tvtime channel names to mplayer
The following script is a workaround to the problem that tvtime doesn't use the same channel names as freevo (cf. freq.py). Ie. S11 in tvtime is SE11 in mplayer. A neater solution would be to edit the tvtime plugin to use freq.py then the above could be used.
The problem with running a script that runs mencoder is how to terminate it cleanly. The VCR_POST_REC kill command is vital that mencoder stops and doesn't eat up your disk space.
/usr/local/bin/record:
# tidying up as mencoder doesn't exit automatically with -endpos
clean_up () {
PID=`pidof mencoder`
if [[ $PID -gt 0 ]]; then
kill -SIGINT $PID # kill mencoder neatly
fi
v4lctl volume mute on # silence tv
amixer -q cset numid=22 on # unsilence aux
exit
}
trap clean_up SIGINT SIGTERM SIGHUP # this doesn't work, hence the -c option for VCR_POST_REC
while getopts "c" Option
do
case $Option in
c ) clean_up;;
esac
done
shift $(($OPTIND - 1))
# start the script
channel=$1; output=$2
if [ -z $output ]; then
echo "Usage: record channel filename"
exit 1
fi
# some settings:
mencoder='/usr/bin/mencoder'
width=768
height=576
adevice=hw.0,0:alsa
# 2 bodges for converting tvtime channel names into mplayer channel names
# U29 -> 29
channel=${channel#U}
# S1-S20 -> SE1-SE20
if [[ ${channel#S} != $channel && ${channel#S} -lt 21 ]]; then
channel="SE${channel#S}"
fi
# mencoder options with deinterlace and index building
options="tv:// -tv driver=v4l2:brightness=53:contrast=26:saturation=50:hue=50:adevice=$adevice:forceaudio:audiorate=32000:amode=1:norm=PAL-BG:input=0:chanlist=europe-west:channel=$channel:width=$width:height=$height:outfmt=yuy2:device=/dev/video0:buffersize=64 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=4000:keyint=30 -idx -oac mp3lame -lameopts br=128:cbr:mode=3 -ffourcc divx -vf pp=md/de,phase=U -o $output"
# start the recording process:
# mute aux
amixer -q cset numid=22 off
# set aux vol
amixer -q cset numid=23 90%
# set capture aux
amixer -q cset numid=26 3
# set capture on
amixer -q cset numid=27 on
# set capture volume
amixer -q cset numid=28 90%
# video mute off
v4lctl volume mute off
$mencoder $optionsThen edit local_conf.py:
VCR_CMD = ( '/usr/local/bin/record' +
' %(channel)s' +
' %(filename)s') # Filled in by Freevo
VCR_POST_REC = ( '/usr/local/bin/record -c') # important!! stop mencoder recording