Skip to content

Instantly share code, notes, and snippets.

@koorchik
Created February 6, 2017 09:03
Show Gist options
  • Save koorchik/95185dd7cc81030faec78de4f3d8adb5 to your computer and use it in GitHub Desktop.
Save koorchik/95185dd7cc81030faec78de4f3d8adb5 to your computer and use it in GitHub Desktop.
Recompress interlaced video from camera to x264
#!/usr/bin/perl
use warnings;
use strict;
my $in = $ARGV[0] || '';
my $out = $ARGV[1] || '';
unless(defined($in) && -e $in) {
die "File [$in] does not exists; $!";
}
unless ($out){
($out = $in) =~ s/\.\w{2,3}$//;
$out = "$out\_compressed.avi";
}
unlink 'divx2pass.log' if -e 'divx2pass.log';
my $pass1 = 'mencoder -vf yadif -ovc x264 -x264encopts subq=7:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b:pass=1:threads=2:bitrate=2500 -nosound -o /dev/null ' . $in;
my $pass2 = 'mencoder -vf yadif -ovc x264 -x264encopts subq=7:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b:pass=2:threads=2:bitrate=2500 -oac mp3lame -lameopts preset=medium -o ' . "$out $in";
system($pass1);
system($pass2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment