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/*>);