From: Alan J. Pippin Date: Thu, 23 May 2013 07:15:20 +0000 (-0600) Subject: New script for recompressing AVCHD video files into x264 mkv files X-Git-Url: http://git.pippins.net/embedvideo/.git/static/%27%20%20%20%20.%20%24GLOBALS%5B%27phpgw%27%5D-%3Elink%28%27inc/jquery/%7Blink_visit%7D?a=commitdiff_plain;h=f6af50099b5160d36517383217b8e089115cf55f;p=videoscripts%2F.git New script for recompressing AVCHD video files into x264 mkv files --- diff --git a/avchd2h264 b/avchd2h264 new file mode 100755 index 0000000..35f6f96 --- /dev/null +++ b/avchd2h264 @@ -0,0 +1,41 @@ +#!/bin/bash + +# Command line options +INPUT=$1 +OUTPUT_DIR=$2 + +# Recommended min quality for 1080p HD = 22 +# Quality 17 ~ 30% of the original size +# Quality 18 ~ 25% of the original size +# Quality 20 ~ 15% of the original size +QUALITY=18 + +if [ -z "$INPUT" ]; then + echo "Usage: $0 input outputdir" + exit 1 +fi + +if [ -z "$OUTPUT_DIR" ]; then + OUTPUT_DIR="." +fi + +FILENAME=`basename "${INPUT%.*}"` +OUTPUT="$OUTPUT_DIR/$FILENAME.mkv" + +# We want our audio to be pass-through, so detect what the audio of the input is encoded with, and tell handbrake to make the output match +AUDIO_CODEC=`avconv -i "$INPUT" 2>&1 | grep "Audio" | sed -r -e 's/.*?Audio: (\S+),.*?/\1/'` +if [ -z "$AUDIO_CODEC" ]; then + echo "-E- Unable to determine audio codec to use for the input video: $INPUT" + exit 1 +fi +AUDIO_ENC="copy:$AUDIO_CODEC" + +echo "-> Converting \"$INPUT\" to 1080p compressed \"$OUTPUT\" file using audio codec $AUDIO_CODEC" + +if [[ -e "$OUTPUT" ]]; then + echo "-E- Output file $OUTPUT already exists. Aborting..." + exit 1 +fi + +HandBrakeCLI -i "$INPUT" -o "$OUTPUT" -f mkv --denoise="weak" -e x264 -q $QUALITY -x b-adapt=2:rc-lookahead=50 -v 2 -E $AUDIO_ENC -a 1 -6 dpl2 --strict-anamorphic --crop 0:0:0:0 --preset="High Profile" +