Project

General

Profile

RE: Automatic cleaning of recordings » mk.mp4.rip.pl

Mark Kirkpatrick, 2013-11-07 19:39

 
1
#!/usr/bin/perl
2
# select title,subtitle,basename from recorded;
3
$mediasrc = '/raid01/dvd';
4
$mediadst = '/raid01/film';
5
%fnhash = ();
6
$fncount = 0;
7
$return = `ls -1 $mediasrc/*/*.mkv`;
8
$return =~ s/\?|\"|\,|\&|\'|\:|\;|\!//msg;
9
$return =~ s/\-//msg;
10
$return =~ s/\t/-/msg;
11
$return =~ s/ /_/msg;
12
print $return;
13
%fnhash = ();
14
$fncount = 0;
15
while ( $return =~ /($mediasrc)\/(\S+)\/(\S+)\.mkv/msg )
16
{
17
  $title = lc("$2.720.ac3.eng.m4v");
18
  $subtitle = $2;
19
  $fname = "$1/$2/$3.mkv";
20
  print "${title}-${subtitle}-${fname}\n"; 
21
  $fnhash{$fname} = "${title}-${subtitle}.m4v";
22
  $fnhash{$fname}{TITLE} = ${title};
23
  $fnhash{$fname}{SUBTITLE} = ${subtitle};
24
  $fncount++;
25
  print "$fnhash{$fname}:\t $serid $fnhash{$fname}{PID} $fnhash{$fname}{PIDNO} $catgry\n";
26
}
27

    
28
# exit 0;
29

    
30
for $mfile ( sort keys %fnhash )
31
{
32
	print "####\n$mfile is $fnhash{$mfile}\n\n";
33
 if ( -e "${mediadst}/$fnhash{$mfile}{TITLE}" )
34
 { 
35
   print "file exists for ${mediadst}/$fnhash{$mfile}{TITLE}\n";
36
 } else {
37
	$retuse = `fuser $mfile`;
38
	if ( $retuse == '' )
39
	{
40
	  print "$mfile not in use .. start encode\n";
41
	if ( $mfile =~ /\.mkv/ ) # change to Switch to decide if blueray or dvd source
42
	{ 
43
####	alternate High Quality = -q 18 -x me=umh:subme=7:b-adapt=2
44
####	alternate Faster Quality = -q 20 -x me=hex:subme=6:b-adapt=1
45
	$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}`;
46
	} else 
47
	{ # 
48
#	$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}`;
49
	} # if ( $mfile =~ /\.mkv/ )
50
	  print "${mediadst}/$fnhash{$mfile}{TITLE} adding itunes atoms\n";
51
	$atomret = `/usr/local/bin/AtomicParsley ${mediadst}/$fnhash{$mfile}{TITLE} --overWrite --stik "Movie"` ;
52
	} #if ( $retuse = '' )
53
 } #else if ( -e "/raid01/film/$fnhash{$mfile}{TITLE}" )
54
}
(1-1/3)