4
# This is a very simple script to record a v4l program with ffmpeg or mencode
5
# Currenlty, works only with PAL-M or NTSC with ntsc-cable freqs
7
# mencode is easier due to usage of ALSA
9
my $station = shift or die "Usage: $0 <station> [standard] [device]";
13
# Parameters with optional values
15
$std=shift or $std='PAL-M';
16
$dev=shift or $dev="/dev/video1";
18
##############################################
19
# Those stuff below are currently "hardcoded"
27
##############################################
28
# Those stuff below are NTSC / PAL-M specific
30
my $list="/usr/share/xawtv/ntsc-cable.list";
34
##############################################
39
open IN,$list or die "$list not found";
43
if (m/freq\s*=\s*(\d+)(\d..)/) {
49
if (m/[\[]($station)[\]]/) {
57
printf "Can't find station $station\n";
61
printf "setting to channel $station, standard $std, freq=$freq on device $dev\n";
62
system "v4l2-ctl -d $dev -f $freq -s $std";
64
printf "Programming alsa to capture on $rec_ctrl at hw $acard\n";
65
system "amixer -c $acard sset $rec_ctrl 80% unmute cap";
66
system "amixer -c $acard sset Capture 15%";
68
printf "recording with ffmpeg on device $dev\n";
70
my $encode="/usr/bin/mencoder -tv driver=v4l2:device=$dev:norm=$std:width=$width:height=$height:input=0:alsa:adevice=hw.".$acard.":amode=1:forceaudio:fps=$fps tv:// -o $file -oac mp3lame -lameopts cbr:br=$abitrate -ovc lavc -lavcopts dia=-2:vcodec=mpeg4:vbitrate=$vbitrate -noodml";
71
#my $encode="ffmpeg -ad /dev/dsp".$acard." -vd $dev -tvstd $std -s ".$width."x".$height." -vcodec mpeg2video -f mpeg test.mpg";