Skip to content

Instantly share code, notes, and snippets.

@warewolf
Created November 23, 2011 15:17
Show Gist options
  • Save warewolf/1388935 to your computer and use it in GitHub Desktop.
Save warewolf/1388935 to your computer and use it in GitHub Desktop.
tivo2avi
#!/usr/bin/env perl
use strict;
use warnings;
while (my $in_file = shift @ARGV)
{
my $out_file = $in_file;
$out_file =~ s/tivo$/avi/i;
unlink("divx2pass.log");
foreach my $pass (qw(1 2 3)) {
my @mencoder = qw( mencoder -ovc lavc -oac copy -vf pullup=16:16,softskip,hqdn3d,pp=hb/vb/dr -fps 30000/1001 -ofps 24000/1001);
push @mencoder, "-vf-add","scale=352:480,crop=320:432:22:22";
push @mencoder, "-lavcopts";
push @mencoder,"vcodec=mpeg4:vhq:v4mv:autoaspect:trell:vqmin=2:vlelim=-4:vcelim=9:lumi_mask=0.05:dark_mask=0.01:mpeg_quant:threads=2:vbitrate=673:";
if ( $pass eq 1 ) {
$mencoder[-1].="turbo:vpass=1";
} else {
$mencoder[-1].="vpass=3";
}
push @mencoder, "-", "-o", $out_file;
print "Running @mencoder\n";
unless (fork) {
pipe R, W;
if (fork) {
open STDOUT, ">&W";
close R;
exec "tivodecode", "-m", "[redacted]", "-o", "-", $in_file;
} else {
open STDIN, "<&R";
close W;
exec @mencoder;
}
}
wait;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment