Skip to content

Instantly share code, notes, and snippets.

@agners
Created June 15, 2013 10:00
Show Gist options
  • Save agners/5787602 to your computer and use it in GitHub Desktop.
Save agners/5787602 to your computer and use it in GitHub Desktop.
WMA to MP3
#!/bin/bash -e
IN=$1
OUT=`echo "$IN"|sed -e 's/wma$/mp3/'`;
echo "Will convert from $IN to $OUT";
echo Extracting...
mplayer -ao pcm:waveheader:file=/tmp/audiodump.wav "$IN" 2>/dev/null > /tmp/taginfo;
echo Encoding...
lame --id3v2-only -m j -h --vbr-new -b 192 "/tmp/audiodump.wav" -o "/tmp/$OUT";
mv "/tmp/$OUT" "$OUT";
echo Fixing ID3 tags
ARTIST=`cat /tmp/taginfo | grep author: | cut -d : -f 2 | iconv -t iso8859-1`
TITLE=`cat /tmp/taginfo | grep title: | cut -d : -f 2 | iconv -t iso8859-1`
ALBUM=`cat /tmp/taginfo | grep album: | cut -d : -f 2 | iconv -t iso8859-1`
echo Artist = \"$ARTIST\"
echo Track Number = \"$NUM\"
echo Title = \"$TITLE\"
id3v2 --artist "$ARTIST" --song "$TITLE" --album "$ALBUM" "$OUT"
rm "$IN"
rm "/tmp/audiodump.wav"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment