Skip to content

Instantly share code, notes, and snippets.

@kanreisa
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanreisa/9709802 to your computer and use it in GitHub Desktop.
Save kanreisa/9709802 to your computer and use it in GitHub Desktop.
#!/bin/bash
EXT="mp4"
PTAG="x264_r14f18p"
ATAG="fdkaac_he96ab"
# m2ts -> m4a
avconv -y -i $1 -vn -map 0:a:0 \
-c:a libfdk_aac -profile:a aac_he -b:a 96k -afterburner 1 \
-f mp4 $1.tmp.m4a
# m2ts -> m4v
HandBrakeCLI -i $1 -a none -v1 \
-w 1280 -l 720 --crop 0:0:0:0 --modulus 2 \
-e x264 --x264-tune ssim -q 18 \
-x b-adapt=2:me=umh:merange=64:subq=10:trellis=2:ref=12:bframes=6:analyse=all:b-pyramid=strict:deblock=2,2 \
-4 -O -f mp4 -o $1.tmp.m4v \
2>&1 | tee $1.tmp.log
SSIM=`cat "$1.tmp.log" | grep SSIM | sed -e "s/^.*Mean Y:\([0-9.]*\).*$/\1/"`
# mux
MP4Box -add "$1.tmp.m4v"#video -add "$1.tmp.m4a"#audio -new "$1.${PTAG}_SSIM=$SSIM.$ATAG.$EXT"
# clean up
rm -fv $1.tmp.m4v $1.tmp.m4a $1.tmp.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment