Updated for Ubuntu 22.04. Also fixed merge videos cmin check
[videoscripts/.git] / mts2mpg
1 #!/usr/bin/perl
2 # transcode_mts-mpg.pl
3 use File::Basename;
4 @files = glob "*.MTS";
5
6 foreach(@files)
7 {
8   print "-> Encoding $_.MTS to $_.mpg\n";
9
10   # Find out if content is interlaced or not
11   $deint_option = "-deinterlace";
12   $progressive = system('ffmpeg -i "$_.MTS" 2>&1 | grep -q "frame rate differs"');
13   if(!$progressive) { 
14     print "   Detected interlaced video content\n";
15   } else { 
16     print "   Detected progressive video content\n";
17     $deint_option = "";
18   }
19
20   # 2 pass encode the video to DVD compatible mpg
21   `ffmpeg -i $_ $deint_option -target ntsc-dvd -pass 1 $_.mpg`;
22   `rm $_.mpg`;
23   `ffmpeg -i $_ $deint_option -target ntsc-dvd -pass 2 $_.mpg`;
24
25 }