Skip to content

Instantly share code, notes, and snippets.

@fzero

fzero/wav1644.sh

Last active Aug 29, 2015
Embed
What would you like to do?
wav1644.sh - Converts .wav files to 16bits/44khz (CD quality)
#!/bin/bash
# wav1644.sh - Converts .wav files to 16bits/44khz (CD quality)
# Many iPad audio apps need this, and it's a good size/quality ratio for
# uncompressed audio anyway. Fuck Neil Young and other clueless audiophiles.
# Download this to somewhere in your $PATH and make it exectutable with
# chmod a+x wav1644.sh
# WAV conversion function - uses ffmpeg
function convertwav {
mv "$1" "$1.original"
ffmpeg -i "$1.original" -acodec pcm_s16le -ar 44100 "$1"
}
# Usage
if [ "$1" == "" ]; then
echo "Usage: $(basename $0) <high sampling rate wav or folder>"
exit 1
fi
# Do it!
if [ -f "$1" ]; then
convertwav "$1"
elif [ -d "$1" ]; then
cd "$1"
for wavfile in *.wav; do
convertwav "$wavfile"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment