#!/usr/bin/perl # transcode_mts-mpg.pl use File::Basename; @files = glob "*.MTS"; foreach(@files) { print "-> Encoding $_.MTS to $_.mpg\n"; # Find out if content is interlaced or not $deint_option = "-deinterlace"; $progressive = system('ffmpeg -i "$_.MTS" 2>&1 | grep -q "frame rate differs"'); if(!$progressive) { print " Detected interlaced video content\n"; } else { print " Detected progressive video content\n"; $deint_option = ""; } # 2 pass encode the video to DVD compatible mpg `ffmpeg -i $_ $deint_option -target ntsc-dvd -pass 1 $_.mpg`; `rm $_.mpg`; `ffmpeg -i $_ $deint_option -target ntsc-dvd -pass 2 $_.mpg`; }