All pastes #2095579 Raw Edit

Anonymous

public text v1 · immutable
#2095579 ·published 2011-11-25 04:19 UTC
rendered paste body
#!/usr/bin/perl
use strict;
use warnings;

($ARGV[0] && $ARGV[1] && $ARGV[2]) ? my ($host, $user, $dir) = ($ARGV[0], $ARGV[1], $ARGV[2]) : die "[err] Usage: ./flowconverter remotefilehost remoteuser /remote/file/path\n";
$dir = $dir . "/" unless $dir =~ /\/$/;

system("rsync -av --copy-links --progress $user\@$host:$dir /tmp/flowtmp/");
my @files = </tmp/flowtmp/*>;
chdir('/tmp/flowtmp');

my $counter=1;
foreach my $file (@files){
   $file =~ s/ /\\ /g;
   print "transcoding file $counter: $file\n\n";
   system("HandBrakeCLI --preset 'iPhone & iPod Touch' --vb 200 --two-pass --turbo --optimize --input $file --output $file.mp4");
   ++$counter;
}

system("rsync -av --copy-links --progress /tmp/flowtmp/*.mp4 $user\@$host:$dir");
unlink(</tmp/flowtmp/*>);