Created
November 4, 2013 20:17
-
-
Save rchrd2/7308579 to your computer and use it in GitHub Desktop.
Helper script to convert wav files to mp3 with ffmpeg.
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 | |
| 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