my $fname="/video$mpg"; $fname =~ s/-[0-9:]*-[0-9]*\.mpg$/.mpg/; $fname =~ s/'/\\\\\\\\x27/g; my $outname="$mpg"; $outname =~ s/\.mpg/.mp4/; #replace "hard" chars in output name $outname =~ s/['"]/_/g; $outname =~ s/&/_/g; my $offset_opts=""; $offset_opts.=" -ss $start" if($start); $offset_opts.=" -t $duration" if($duration); my $opts = " -b 99999 -acodec aac -ab 256 -async 1 \"$outname\""; #wish we could do a pipe, but that confuses ffmpeg my $cmd="ssh ffmpeggen\@$host 'x=`printf \"$fname\"`; ffmpeg $offset_opts -i \"\$x\" $opts';"; open(my $fh, "$cmd |"); my $out=<$fh>; close($fh);