Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewfitz/d22f1c93628d23f6930c to your computer and use it in GitHub Desktop.
Save andrewfitz/d22f1c93628d23f6930c to your computer and use it in GitHub Desktop.
This is an OS X shell script to run in terminal. It will loop through all files in the
current directory and convert them with handbrakecli. The settings are for as close to
the same as what comes from the iPhone or iPad h.264, the audio is just passed through AAC.
The file size will be within about +-5% of the original, same resolution and bitrate.
The fix is for videos that were recorded upside down using iOS and the variable framerate
Apple uses to record that makes the audio get way out of sync in Adobe Premire. Remove
the --rotate param if you don't need it. Use these settings to quickly (fastest encoding
settings) make any iPhone or iPad video compatible with Adobe Prelude, After Effects, or Premire.
for fileIn in `ls *.MOV`; do fileOut=$(echo $fileIn | sed -e 's/.MOV/.m4v/g'); HandBrakeCLI --rotate -e x264 -E copy -b 12000 -x level=4.1:ref=1:scenecut=0:bframes=0:no-deblock=1:cabac=0:analyse=none:8x8dct=0:weightp=0:me=dia:subme=0:mixed-refs=0:trellis=0:vbv-bufsize=62500:vbv-maxrate=50000:aq-mode=0:mbtree=0:rc-lookahead=0 -r 29.97 -P -i $fileIn -o $fileOut; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment