Last active
December 21, 2015 08:38
-
-
Save ifnull/6279504 to your computer and use it in GitHub Desktop.
Encode videos for Vine
This file contains hidden or 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
1. Download http://handbrake.fr/rotation.php?file=HandBrake-0.9.9-MacOSX.6_CLI_x86_64.dmg | |
2. Mount HandBrake-0.9.9-MacOSX.6_CLI_x86_64.dmg | |
3. Copy HandBrakeCLI to /Applications/HandBrakeCLI |
This file contains hidden or 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
sudo ln -s /Applications/HandBrakeCLI /usr/bin/handbrake |
This file contains hidden or 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/perl | |
my @dimensions = split('x', $ARGV[0]); | |
my $srcWidth = $dimensions[0]; | |
my $srcHeight = $dimensions[1]; | |
my $input = $ARGV[1]; | |
my $output = $ARGV[2]; | |
my $crop = ""; | |
my $startAt = 0; | |
if($#ARGV > 3) { | |
$startAt = $ARGV[4]; | |
} | |
if($#ARGV > 2) { | |
$crop = $ARGV[3]; | |
} else { | |
if ($srcWidth >= $srcHeight) { | |
$cropAmount = int(($srcWidth-$srcHeight) + 0.99) /2; | |
$crop = "0:0:$cropAmount:$cropAmount"; | |
} else { | |
$cropAmount = int(($srcHeight-$srcWidth) + 0.99) /2; | |
$crop = "$cropAmount:$cropAmount:0:0"; | |
} | |
} | |
my $cmd="handbrake ". | |
" --input $input". | |
" --output $output". | |
" --format mp4". | |
" --encoder x264". | |
" --vb 500". | |
" --rate 24". | |
" --vfr". | |
" --quality 20". | |
" --encopts level=3.0:weightp=0:subq=7:vbv-bufsize=10000:vbv-maxrate=10000:rc-lookahead=30:8x8dct=1:cabac=1:bframes=1:ref=1". | |
" --maxHeight 480". | |
" --maxWidth 480". | |
" --height 480". | |
" --width 480". | |
# " --start-at-preview". | |
" --start-at duration:$startAt". | |
" --stop-at duration:5". | |
" --crop $crop". | |
" --custom-anamorphic". | |
" --pixel-aspect 480:480". | |
" --itu-par". | |
" --display-width 480". | |
" --modulus 2". | |
" --markers". | |
" --audio 1". | |
" --aencoder faac". | |
" --mixdown mono". | |
" --arate 44.1". | |
" --ab 160". | |
" --drc 0.0". | |
" --gain 0.0". | |
" --audio-copy-mask aac,ac3,dtshd,dts,mp3". | |
" --audio-fallback ffmpeg"; | |
print STDERR "$cmd\n"; | |
system($cmd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment