#!/usr/bin/perl # select title,subtitle,basename from recorded; $mediasrc = '/raid01/dvd'; $mediadst = '/raid01/film'; %fnhash = (); $fncount = 0; $return = `ls -1 $mediasrc/*/*.mkv`; $return =~ s/\?|\"|\,|\&|\'|\:|\;|\!//msg; $return =~ s/\-//msg; $return =~ s/\t/-/msg; $return =~ s/ /_/msg; print $return; %fnhash = (); $fncount = 0; while ( $return =~ /($mediasrc)\/(\S+)\/(\S+)\.mkv/msg ) { $title = lc("$2.720.ac3.eng.m4v"); $subtitle = $2; $fname = "$1/$2/$3.mkv"; print "${title}-${subtitle}-${fname}\n"; $fnhash{$fname} = "${title}-${subtitle}.m4v"; $fnhash{$fname}{TITLE} = ${title}; $fnhash{$fname}{SUBTITLE} = ${subtitle}; $fncount++; print "$fnhash{$fname}:\t $serid $fnhash{$fname}{PID} $fnhash{$fname}{PIDNO} $catgry\n"; } # exit 0; for $mfile ( sort keys %fnhash ) { print "####\n$mfile is $fnhash{$mfile}\n\n"; if ( -e "${mediadst}/$fnhash{$mfile}{TITLE}" ) { print "file exists for ${mediadst}/$fnhash{$mfile}{TITLE}\n"; } else { $retuse = `fuser $mfile`; if ( $retuse == '' ) { print "$mfile not in use .. start encode\n"; if ( $mfile =~ /\.mkv/ ) # change to Switch to decide if blueray or dvd source { #### alternate High Quality = -q 18 -x me=umh:subme=7:b-adapt=2 #### alternate Faster Quality = -q 20 -x me=hex:subme=6:b-adapt=1 $hbret = `/usr/local/bin/HandBrakeCLI -i ${mfile} -I -v -e x264 -q 18 --loose-anamorphic -a 1,1 -E faac,copy:ac3 -B 128,auto -6 dpl2 -f m4v -Y 480 -X 960 -N eng -s 1,2 -m -x me=umh:subme=7:b-adapt=2 -o ${mediadst}/$fnhash{$mfile}{TITLE}`; } else { # # $hbret = `/usr/local/bin/HandBrakeCLI -i ${mfile} -I -v --loose-anamorphic -e x264 -q 18 -a 1,1 -E faac,copy:ac3 -B 128,auto -6 dpl2 -f m4v -Y 480 -X 960 -N eng -s 1,2 -m -x me=umh:subme=7:b-adapt=2 -o ${mediadst}/$fnhash{$mfile}{TITLE}`; } # if ( $mfile =~ /\.mkv/ ) print "${mediadst}/$fnhash{$mfile}{TITLE} adding itunes atoms\n"; $atomret = `/usr/local/bin/AtomicParsley ${mediadst}/$fnhash{$mfile}{TITLE} --overWrite --stik "Movie"` ; } #if ( $retuse = '' ) } #else if ( -e "/raid01/film/$fnhash{$mfile}{TITLE}" ) }