#!/usr/bin/perl # # tvrec.pl -c channel -t HH:MM:SS -o out.avi # $channel = ""; $endpos = ""; $file = ""; if ( @ARGV eq 0 ) { print "usage: tvrec.pl -c channel -t HH:MM:SS -o out.avi\n"; exit -1; } while ( @ARGV ) { $_ = shift @ARGV; if ( /-c/ ) { $channel = shift @ARGV; } elsif ( /-t/ ) { $endpos = shift @ARGV; } elsif ( /-o/ ) { $file = shift @ARGV; } else { print "unknown option: " . $_ . "\n"; exit -1; } } if ( $channel eq "" ) { print "channel is not specified\n"; exit -1; } if ( $endpos eq "" ) { print "time is not specified\n"; exit -1; } if ( $file eq "" ) { print "output file is not specified\n"; exit -1; } $cmd1 = "v4lctl -c /dev/video0 setnorm NTSC"; # この設定だと,Celeron 2.4GHz で CPU 占有率は 70% 弱くらい. $cmd2 = "mencoder " # nice -19 mencoder (優先度最高) だと映像と音がズレる. . "-vop scale=640:480,crop=624:468:8:0,pp=lb " . "-tv driver=v4l2:device=/dev/video0:input=1:amode=1 " . "-tv norm=NTSC:width=640:height=480 " . "-tv chanlist=japan-bcast:channel=$channel " . "-ovc lavc " . "-lavcopts vcodec=mpeg4:vbitrate=1025 " # -lameopts に aq=0 (音質最高) を指定すると映像と音が完全にズレる. . "-oac mp3lame -lameopts cbr:br=128 " . "-endpos $endpos " . "tv:// " . "-o $file"; system($cmd1) eq 0 or die "system $cmd1 faild: $?\n"; system($cmd2) eq 0 or die "system $cmd2 faild: $?\n";