Skip to content

Instantly share code, notes, and snippets.

@kennyng
Created December 1, 2015 08:36
Show Gist options
  • Save kennyng/3aae777d97e4fe6628e8 to your computer and use it in GitHub Desktop.
Save kennyng/3aae777d97e4fe6628e8 to your computer and use it in GitHub Desktop.
Convert Audio Tracks to .wma
#!/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