Created
May 19, 2014 20:19
-
-
Save stouset/eeb5ac06878a6a54aa3d to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
CAFOPTS="--soundcheck-generate" | |
AACOPTS="--soundcheck-read -u pgcm 2 -b 256000 -q 127 -s 2" | |
DIR=`dirname "$1"` | |
BASENAME=`basename "$1" .flac` | |
FLAC=$DIR/$BASENAME.flac | |
AAC=$DIR/$BASENAME.m4a | |
[ -e "$1" -a "$1" = "$FLAC" ] || exit 1 | |
WAV=`mktemp -t $(basename $0).wav` | |
CAF=`mktemp -t $(basename $0).caf` | |
trap "rm $WAV $CAF" EXIT | |
ffmpeg -y -i "$FLAC" -f wav -acodec pcm_s16le "$WAV" -loglevel fatal && \ | |
afconvert "$WAV" "$CAF" -d 0 -f caff $CAFOPTS && \ | |
afconvert "$CAF" "$AAC" -d aac -f m4af $AACOPTS || \ | |
echo "Failed to reencode \"$1\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment