recdvb
#!/usr/bin/perl # # (c) Ing. Peter Grobner # # v20090727 bugfix default $end=.../60; test $adapt within the loop; my %UMLAUT=( 0x84 => 'Ae', 0x96 => 'Oe', 0x9c => 'Ue', 0xa4 => 'ae', 0xb6 => 'oe', 0xbc => 'ue', 0x9f => 'ss' ); @ARGV=map { s/\xC3(.)/$UMLAUT{ord($1)}/ge; s/[^-.:\w\/ ]//g; $_ } @ARGV; my $argv=join ' ',map { /\s/? "\\\"$_\\\"":$_; } @ARGV; if($argv=~s/--?at\s+(\d\d):(\d\d)//g) { print qx(echo "recdvb $argv"|at -t "$1:$2"); exit; } if($argv=~s/--?at\s+(\d\d\d\d)-(\d?\d)-(\d?\d)\s+(\d?\d):(\d?\d)//g) { my $datetime=sprintf("%04d%02d%02d%02d%02d",$1,$2,$3,$4,$5); print qx(echo "recdvb $argv"|at -t $datetime); exit; } if($argv=~s/--?rm\s+(\d\d\d\d)-(\d?\d)-(\d?\d)\s+(\d?\d):(\d?\d)//g) { my $datetime=sprintf("%04d-%02d-%02d\\s%02d:%02d",$1,$2,$3,$4,$5); my $atq=qx(atq); $atq=~s/^(\d+)\s+$datetime\s/qx(atrm $1)/meg; exit; } if($argv=~/^--?ls?$/i) { my $jobs=qx(grep recdvb /var/spool/cron/atjobs/*|cut -c24-|sort -k1.7); # /var/spool/atjobs/a001c3013e836a:recdvb $jobs=~s{^\w(\w{5})(\w{8}):recdvb} { hex($1).': '.localtime(60*hex($2)); }meg; print $jobs; exit; } my $time =qx{date "+%F_%R"}; $time=~s/[^-\w]//g; my $scale='720:576'; my $asp ='autoaspect'; my $end =qx(date +\%s -d "now +1 hour +40 minutes")/60; my $chan ='ORF1'; my $path ='/home/global/DVDs/'; my $file =sprintf("%s_%s",'orf1',$time); my $part ='a'; my $r =''; foreach(@ARGV) { $end =qx(date +\%s -d "now +$1 hour +$2 minutes")/60 if(/^(\d+):(\d+)$/); $path.='/Kinderfilme/' if(/^-k/i); $path.="/$1" if(/^\/(.*)$/); $asp ="aspect=$1" if(/^(4\/3|16\/9)$/); $file =sprintf('%s_%s','atv', $time),$chan='ATV' if(/(atv)/i); $file =sprintf('%s_%s','orf1',$time),$chan='ORF1' if(/(orf1)/i); $file =sprintf('%s_%s','orf2',$time),$chan='ORF2' if(/(orf2)/i); $file =sprintf('%s_%s','orf2',$time),$chan='ORF2-N' if(/(orf2-?n)/i); $file =sprintf('%s_%s','orf2',$time),$chan='ORF2-W' if(/(orf2-?w)/i); $file =sprintf('%s_%s','orf3',$time),$chan='ORF3' if(/(orf3)/i); } $path=~s/://g; my $p=$path; $p=~s/\/[^\/]+$//; qx{mkdir -p "$p"; chmod a+rwx "$p"} if($p && !-d $p); while(1) { my $now=qx(date +\%s)/60; last if($end<=$now); my $time=sprintf("%d:%02d",($end-$now)/60,($end-$now)%60); my $ps=qx{ps axo command|grep "^mencoder dvb:"}; my $adapt=''; $adapt='1@' if($ps!~m{dvb://1@}); $adapt='2@' if($ps!~m{dvb://2@}); next if(!$adapt); my $null='2>/dev/null'; $null=''; qx{mencoder dvb://$adapt$chan -quiet -endpos $time:00 -oac copy -vf pp=lb -lavcopts $asp -ovc lavc -ffourcc DX50 -forceidx -o "$path$file$part.avi" $null}; qx{chmod a+rw "$path$file$part.avi" $null}; if(4108 == -s "$path$file$part.avi") { qx{rm "$path$file$part.avi" $null}; next; } $part++; }
Aufnahme vom DVB-T Stick programmieren und abwickeln(3.2kB)
Download