WMA to OGG file conversion September 29, 2005
Posted by Carthik in snippets, ubuntu.trackback
Karl Hegbloom was kind enough to post to the ubuntu-users mailing list wanting to share his script to convert .wma files to .ogg files. The conversions needs the mplayer and the oggenc packages to be installed on your system. The script is pasted below:
#!/bin/sh
# Convert a .wma to an .ogg using ‘mplayer’ and ‘oggenc’.
#
# Public Domain
set -e
IN=$1
shift
if [ -z “${IN}” ]; then
IN=-
WAV=audio.wav
else
WAV=$(basename ${IN} .wma).wav
fi
mplayer -vc dummy -vo null -ao pcm:waveheader:file=${WAV} ${IN}
FILEDAT=$(file ${WAV})
BITS=$(echo ${FILEDAT} | sed -e ‘s/.*\(8\|16\|32\) bit.*/\1/’)
if echo ${FILEDAT} | grep -q mono; then
CHANS=1
else
CHANS=2
fi
oggenc -R 44100 -B ${BITS} -C ${CHANS} ${WAV} >/dev/null
rm -f ${WAV}
I posted a script that converted from wma to mp3 a while back.
This script looks a lot more complete though! Next time I need to convert files I’ll look back here! 🙂
It is nice since you can save it for later as a .sh script, but your method is cool too – it is so short, and simple 🙂
This is extremely usefull to many windows migraters. May I suggest to write a howto on implementing the script for newbies in the Linux world?
Cheers.
Pascal
For those who may be wondering, the ‘oggenc’ program may be obtained by a ‘sudo apt-get install vorbis-tools’
For those running breezy, there is a nice gui program called soundconverter that can do this.
Just a note that wma files with spaces in the name will cause an error with this script.
Is there a script fix or do we just need to rename the files before running the script?
Just guessing, but I think you need to put quotes around ${IN} and ${WAV}, so that
mplayer -vc dummy -vo null -ao pcm:waveheader:file=${WAV} ${IN}
becomes
mplayer -vc dummy -vo null -ao pcm:waveheader:file=”${WAV}” “${IN}”
and
oggenc -R 44100 -B ${BITS} -C ${CHANS} ${WAV} >/dev/null
becomes
oggenc -R 44100 -B ${BITS} -C ${CHANS} “${WAV}” >/dev/null
and
rm -f ${WAV}
becomes
rm -f “${WAV}”
Personally though, I’d just replace the spaces with underscores.
If you want to start a whole directory converting and then forget about, use this simple for loop:
for f in *.wma; do “$f”; done;
Of course don’t forget the final step after the converting is done:
rm *.wma
😉
oops, my “scriptname here” between the “do” and the “$f” got edited out because I used less-than/greater-than signs.
Really a good script!
However, when try with filenames with spaces, the script go down. A few bytes fix it.
#!/bin/sh
# Convert a .wma to an .ogg using mplayer and oggenc.
#
# Public Domain
set -e
IN=$1
echo $IN
shift
if [ -z “${IN}” ]; then
IN=-
WAV=audio.wav
else
WAV=$(basename “${IN}” .wma).wav
fi
mplayer -vc dummy -vo null -ao pcm:waveheader:file=”${WAV}” “${IN}”
FILEDAT=$(file “${WAV}”)
BITS=$(echo ${FILEDAT} | sed -e ‘s/.*\(8\|16\|32\) bit.*/\1/’)
if echo ${FILEDAT} | grep -q mono; then
CHANS=1
else
CHANS=2
fi
oggenc -R 44100 -B ${BITS} -C ${CHANS} “${WAV}” >/dev/null
rm -f “${WAV}”
Thx Karl, thx ubuntonista.
Regards
Alejandro Salamanca
RedCetus
Convert WMA to OGG
Screw those evil M$ formats!
(You’ll need (media-sound/)vorbis-tools for this to work)
#!/bin/sh
# Convert a .wma to an .ogg using mplayer and oggenc.
#
# Public Domain
set -e
IN=$1
echo $IN
shift
if [ -z “${IN}” ]; then
IN=-
WAV=audio.wav
el…
Here is a similar script I made to encode mp3.
It can recursively look for files in subdirectories by passing -r, as well as it can remove the wma file for you by passing -d. The script does not need to remove any whitespaces, so you can use nice file names! ;D
It is a bit too long to post it here, so plz use this link: http://88.198.16.39/seek/make-mp3
If you want to create .ogg vorbis files, just change the second functions on the top to use oggenc.
I hope somebody will find this script usefull really, since it’s one of the first shellscripts I made. (filenames with whitespaces are cruel if you don’t know how to handle it ^^;)
Please send a mail if you have some improvements and/or better ideas.
Have a lot of fun!
Bernhard
Bernhard – the top of the script needs to be /bin/bash not /bin/sh or you get an error on the ‘function’ lines.
http://www.oggconvert.com
online tool to convert ogg files, no downloads
works better on smaller files because it’s web based
You can also go too http://www.oggconvert.com/ to convert OGG files to MP3, AAC, FLAC, OGG, WMA, M4A, WAV online. I hope its big help.
You can also go to http://www.oggconvert.com/ to convert OGG files to MP3, AAC, FLAC, OGG, WMA, M4A, WAV online. I hope its big help.
I posted a script that converted from wma to mp3 a while back.
This script looks a lot more complete though! Next time I need to convert files I’ll look back here
teşekkürler paylaşım için çok hoş olmuş