Skip to content

Instantly share code, notes, and snippets.

@rchrd2
Created November 4, 2013 20:17
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 rchrd2/7308579 to your computer and use it in GitHub Desktop.
Save rchrd2/7308579 to your computer and use it in GitHub Desktop.
Helper script to convert wav files to mp3 with ffmpeg.
#!/bin/bash
BITRATE=320
defvalue='.'
SOURCE_DIR=${1:-$defvalue}
# Validate arguments
if [[ "$#" == 0 ]]; then
echo >&2 "Usage: ./convert.sh ./exports/*.wav"
exit 1;
fi
# Validate requirements
command -v ffmpeg >/dev/null 2>&1 || { echo >&2 "please install ffmpeg (brew install ffmpeg)"; exit 1; }
FILES="$@"
for I in $FILES
do
# Convert wav to mp3 using ffmpeg
echo "Converting $I..."
ffmpeg -i "${I}" -b:a ${BITRATE}k "${I/%.wav/.mp3}" >/dev/null 2>&1
echo "done!"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment