Created
December 18, 2017 20:34
-
-
Save fredmajor/26283a14e6ca0fb9606f494870d44f86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use File::Basename; | |
use Cwd 'abs_path'; | |
use 5.014; | |
use strict; | |
use warnings; | |
use utf8; | |
my $CRF=18; | |
my $PRESET="slow"; | |
my $TARGET_WIDTH="1280"; | |
my $TARGET_EXT=".mp4"; | |
my $SUFFIX="_PRESET_" . $PRESET . "_CRF_" . $CRF . "_W_" . $TARGET_WIDTH.$TARGET_EXT; | |
my $argcount=@ARGV; | |
for (my $c=0; $c < $argcount; $c++){ | |
my $currFile = abs_path(shift); | |
my($filename, $dirs, $suffix) = fileparse($currFile); | |
(my $without_extension = $filename) =~ s/\.[^.]+$//; | |
my $fOutBasename = $without_extension . $SUFFIX; | |
my $fOut = $dirs . $fOutBasename; | |
say "fOut:" . $fOut; | |
#my $cmd1 = qq{ffmpeg -y -i "$currFile" -c:v libx264 -preset $PRESET -profile:v high -crf $CRF -vf scale=$TARGET_WIDTH:-1 -pix_fmt yuv420p -r 30000/1001 -c:a aac -b:a 256k -ac 2 "$fOut"}; | |
my $cmd1 = qq{ffmpeg -y -i "$currFile" -c:v libx264 -preset $PRESET -profile:v high -crf $CRF -pix_fmt yuv420p -r 24 -c:a aac -b:a 256k -ac 2 "$fOut"}; | |
say "Command is: ". $cmd1; | |
system $cmd1; | |
if ( $? == 0 ) { | |
say "convertion successful" | |
} | |
else { | |
say "convertion failed" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment