Created
December 1, 2015 08:36
-
-
Save kennyng/3aae777d97e4fe6628e8 to your computer and use it in GitHub Desktop.
Convert Audio Tracks to .wma
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
#!/usr/bin/env bash | |
which ffmpeg > /dev/null || { echo "REQUIRED: sudo apt-get install ffmpeg" >&2; exit 1; } | |
which ffprobe > /dev/null || { echo "REQUIRED: sudo apt-get install ffmpeg" >&2; exit 1; } | |
format=mp3 | |
find . -type f | grep -i wma$ > tracklist.txt | |
#readarray -t files < tracklist.txt | |
declare -a tracklist | |
let i=0 | |
while IFS=$'\n' read -r filename; do | |
tracklist[i]="${filename}" | |
((++i)) | |
done < tracklist.txt | |
num_tracks=${#tracklist[@]} | |
for ((i = 0; i < $num_tracks; i++)); do | |
track=${tracklist[i]}; | |
output=${track%.wma}.$format | |
probe=`ffprobe -show_streams "$track" 2>/dev/null` | |
bitrate=`echo "$probe" | grep "^bit_rate" | sed "s:.*=\(.*\)[0-9][0-9][0-9][.].*:\1:" | head -1` | |
ffmpeg -i "$track" -ab 128k "$output" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment