Created
June 26, 2017 20:31
-
-
Save rhietala/8dcb33058fa30d9f37a9903e52df097b to your computer and use it in GitHub Desktop.
Convert flac to aac (m4a)
This file contains 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 | |
# | |
# Convert all .flac music files to .m4a (aac) for itunes/ios use | |
# | |
# Install ffmpeg with fdk_aac (uninstall first if built without it): | |
# $ brew install ffmpeg --with-fdk-aac | |
# | |
# The script assumes the following directory structure: | |
# ./musiikkia/ | |
# ./musiikkia/whatever/song.flac | |
# ./aac/ | |
# ./aac/whatever/song.m4a | |
# | |
# and the script must be run from . | |
# | |
# Change occurrences of 'musiikkia' and 'aac' to suit your needs. | |
find "./musiikkia" -type d -print0 | while IFS= read -r -d '' flacdir | |
do | |
aacdir=`echo "$directory" | sed -e 's/musiikkia\//aac\//'` | |
[ -d "$aacdir" ] && continue # skip if aac-directory exists | |
mkdir -p "$aacdir" | |
done | |
find "./musiikkia" -name *.flac -print0 | while IFS= read -r -d '' input | |
do | |
output=`echo "$input" | sed -e 's/musiikkia\//aac\//' | sed -e 's/flac$/m4a/'` | |
[ -f "$output" ] && continue # skip if file exists | |
echo "" | |
echo "$input" | |
echo "$output" | |
echo "" | |
ffmpeg -i "${input}" -c:a libfdk_aac -vbr 3 -vn -n "${output}" < /dev/null | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment