Updated for Ubuntu 22.04. Also fixed merge videos cmin check
[videoscripts/.git] / organize_movies
index 290f37ce36f011422880c1bfcf7da11a5b6c980f..f64787b7c0760187f83e24b033cde03cdbfc48d9 100755 (executable)
@@ -32,7 +32,7 @@ exit if $pidfile->running();
 $pidfile->write();
 
 # Encode the movies
-encode_movies($mobile_movie_src_dir, $mobile_movie_dst_dir);
+#encode_movies($mobile_movie_src_dir, $mobile_movie_dst_dir);
 encode_movies($movie_src_dir, $movie_dst_dir);
 
 sub encode_movies {
@@ -56,6 +56,7 @@ sub encode_movies {
            my $stat = stat("$movie");
            if($stat->mtime < ($now - $minage*60)) {
                my ($base, $dir, $ext) = fileparse($movie,'\..*');
+                $base =~ s/_t\d+$//g; # remove any extra title numbers from the name
                my $output = "$movie_dst_dir/$category/$base.mkv";
                print "-> Encoding $movie => $output\n";
                my $date = `date`; chomp $date;
@@ -64,15 +65,19 @@ sub encode_movies {
                my $cmd = "HandBrakeCLI";
                $cmd .= " -i \"$movie\" -o \"$output\"";
                $cmd .= " -f mkv --loose-anamorphic --denoise=\"weak\" -e x264";
-               $cmd .= " -a 1,1";
+               #$cmd .= " -a 1,1";
+               $cmd .= " -N eng";
+               $cmd .= " --audio-lang-list eng";
+               $cmd .= " --first-audio";
                $cmd .= " -x b-adapt=2:rc-lookahead=50 -v 2";
                if($category =~ /Mobile/i || $movie_src_dir =~ /Mobile/i || $movie_dst_dir =~ /Mobile/i) {
-                   $cmd .= " --preset=\"Android Tablet\" -2 -B 256";
+                   $cmd .= " --preset=\"Android 720p30\" -2 -B 256";
                } else {
                    $cmd .= " -q $quality";
-                   $cmd .= " -6 6ch";
-                   $cmd .= " -E copy:ac3";
-                   $cmd .= " --preset=\"High Profile\"";
+                   #$cmd .= " -6 6ch";
+                   $cmd .= " -E copy";
+                   $cmd .= " --audio-copy-mask ac3,eac3,truehd,dts,dtshd";
+                   $cmd .= " --preset=\"HQ 1080p30 Surround\"";
                }
                print "   $cmd\n";
                my $errno = system("$cmd > $encode_log 2>&1");