WMA stands for Windows Media Audio, an audio data compression technology. Some players can handle WMA data directly, but many require MP3 (or, to be technical, MPEG-1 Audio Layer 3).
WMA data may be encapsulated within an ASF, or Advanced Systems Format, container file. ASF provides metadata, similar to ID3 tags in MP3 files, and may include digital rights management to limit your ability to play your music.
To convert foo.wma to foo.mp3
just run this sequence of commands:
$ mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader foo.wma $ lame -m s -h audiodump.wav -o foo.mp3 $ mp3info -a "Artist name" -t "Song title" -l "Album name" foo.mp3
If you have a bunch of files, there's a good chance that the file names contain embedded spaces, punctuation marks, and other Windows detritus. So you need to be careful when you automate this. Something like the following should work, use find to invoke a script:
$ cat convertor
#!/bin/sh
mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader "$1"
lame -m s -h audiodump.wav -o "`echo $1 | sed 's/wma/mp3/'`"
$ find *.wma -exec ./convertor {} \;
Then go through and label the files with mp3info.
FLAC stands for Free Lossless Audio Codec, another audio data compression algorithm. Unlike WMA and MP3, FLAC is lossless. This comes at the expense of larger file size, of course. And while FLAC is an excellent compression algorithm for lossless archival storage, players likely require MP3.
To convert foo.flac to foo.mp3
$ flac -dc foo.flac | lame -h -b 192 /dev/stdin foo.mp3 $ mp3info -a "Artist name" -t "Song title" -l "Album name" foo.mp3
Here's a shell script that will do the conversion,
including extracting the FLAC tags and inserting
them as MP3 tags in the result.
Call it as something like:
/path/to/script foo.flac
and the result will be a new file named foo.mp3
#!/bin/sh
FLAC_FILE=$1
MP3_FILE=`echo ${FLAC_FILE} | sed 's/\.flac/.mp3/'`
metaflac --export-tags-to=/dev/stdout "${FLAC_FILE}" |
sed -e 's/=/="/' -e 's/$/"/' > /tmp/tags-$$
cat /tmp/tags-$$
. /tmp/tags-$$
rm /tmp/tags-$$
flac -dc "${FLAC_FILE}" |
lame -h -b 192 \
--tt "${TITLE}" \
--tn "${TRACKNUMBER}" \
--ty "${DATE}" \
--ta "${ARTIST}" \
--tl "${ALBUM}" \
--tg "${GENRE}" \
--add-id3v2 /dev/stdin "${MP3_FILE}"
Yes, if the creators of the FLAC file got overly imaginative with metacharacters within the tags, or just used strange strings for the "Genre" field, the above won't work precisely as written. Delete the optional tag parameters as needed.
|
|
|
|||||||||
|
|||||||||
|
| © Bob Cromwell Feb 2012. Created with /bin/vi and ImageMagick, hosted on OpenBSD with Apache. Root password available here, privacy policy here. |