LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-29-2003, 05:35 PM   #1
andrewlkho
Member
 
Registered: Jul 2003
Location: London
Posts: 548

Rep: Reputation: 31
convert wma > mp3?


Hi,
Can anyone suggest some good software for converting wma's [nasty things ] into mp3's?
Thanks,
 
Old 07-29-2003, 06:32 PM   #2
Corin
Member
 
Registered: Jul 2003
Location: Jette, Brussels Hoofstedelijk Gewest
Distribution: Debian sid, RedHat 9, Suse 8.2
Posts: 446

Rep: Reputation: 31
MP3s are nasty things too! :+)

You should be using the GPL format OGG.

Since WMA is a proprietary format, that is why you do not find any
native GNU software to convert WMAs to MP3.

One possibility would be to run a Windoze conververter program wma -> mp3 under wine.

The other would be to look at the options of mencoder which comes with MPlayer which is able to handle WMA files since it uses the Windoze dlls.
 
Old 07-30-2003, 06:03 PM   #3
Thymox
Senior Member
 
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Mostly Debian based systems
Posts: 4,368

Rep: Reputation: 64
Haha! MPLAYER to the rescue!

If you have the win32 codecs installed (also available from mplayer's site) then you can not only play WMA/WMV files, you can also convert them!

mplayer file.wma -ao pcm -aofile file.wav will convert to a wav file from which you can convert to an mp3/ogg yourself, or there are options to convert straight to mp3... I just can't remember them I know it has been touched upon quite recently though (I think it was something to do with extracting the audio from .mov files).
 
Old 08-26-2003, 03:39 PM   #4
ravnx
LQ Newbie
 
Registered: Jun 2002
Location: Houston, TX
Distribution: Gentoo, Slackware
Posts: 11

Rep: Reputation: 0
Yes, mplayer is the one!

after reading the man pages, couldn't find anything to stream the sound to STDOUT or to an MP3, but you can simply use lame to convert to mp3 "lame -h infile.wav outfile.mp3" or to convert to ogg " oggenc infile.wav"
 
Old 08-27-2003, 05:33 AM   #5
glj
Member
 
Registered: Jul 2001
Location: London
Distribution: RH 9
Posts: 151

Rep: Reputation: 30
You do realize then that you are compressing a compressed file?
The original file will be compressed to the WMA format, which will introduce audio artefacts, and then compressing that file with even more artefacts!
If you're happy with the output though, go for it

glj
 
Old 08-27-2003, 09:29 AM   #6
ravnx
LQ Newbie
 
Registered: Jun 2002
Location: Houston, TX
Distribution: Gentoo, Slackware
Posts: 11

Rep: Reputation: 0
Yes, the original file is WMA a compressed format, but the problem here is that it's not an mp3 or ogg. Therefor I cannot play in xmms or burn it to a cd with other mp3s and oggs via K3B. When I use mplayer to convert wma to wav, mplayer is "playing" the wma file into a wav file, so, in essence, it is creating a totally new file that is not compressed. From that I produce an mp3/ogg file.

I don't see how you are saying that I am compressing an already compressed file.
 
Old 08-27-2003, 09:47 AM   #7
Corin
Member
 
Registered: Jul 2003
Location: Jette, Brussels Hoofstedelijk Gewest
Distribution: Debian sid, RedHat 9, Suse 8.2
Posts: 446

Rep: Reputation: 31
The WAV file that is created by uncompressing the WMA is not the original WAV file.

It suffers from the compression artefacts introduced when the WMA file was created from the original WAV file.

When you compress that with MP3 of OGG software, you then introduced MP3 or OGG compression artefacts as well as including the WMA compression artefacts.

How good the sound quality is, very much depends on what bitrate was used for the original compression to WMA.
 
Old 08-27-2003, 10:15 AM   #8
ravnx
LQ Newbie
 
Registered: Jun 2002
Location: Houston, TX
Distribution: Gentoo, Slackware
Posts: 11

Rep: Reputation: 0
agreed.
 
Old 08-28-2003, 04:28 AM   #9
glj
Member
 
Registered: Jul 2001
Location: London
Distribution: RH 9
Posts: 151

Rep: Reputation: 30
What Corin said!
If you want an MP3 or OGG (preferably), then use the original source, CD probably. You do have the original don't you....
 
Old 08-28-2003, 09:29 AM   #10
ravnx
LQ Newbie
 
Registered: Jun 2002
Location: Houston, TX
Distribution: Gentoo, Slackware
Posts: 11

Rep: Reputation: 0
i dont have the original. that's why this all came about, there are sometimes instances where you are looking for a song and you can ONLY find it on WMA, which is why we are on this discussion.
 
Old 09-08-2003, 11:08 AM   #11
smc_one
LQ Newbie
 
Registered: Jul 2003
Posts: 11

Rep: Reputation: 0
I was reading this post, as I was in the same situation..

I decided to just stop and write a little perl program to:

1) Read all .wma files in a directory and with each one:
2) Use mplayer to make a converted copy to wav file
3) Use lame to convert the wav file to mp3
4) Remove the wav file

When complete, you will end up with an .mp3 copy of each .wma file. Im not an audio codec expert by any means, so there may be switches to make it faster/more efficient/etc.. Im also not responsible if something does not work right - but for me this works great.

Just copy the code below starting at "#! /usr/bin/perl" into a new text file, name it "convert.pl" or whatever you wish - place the file in the folder with the wma files.. then run it from the command line "perl convert.pl" - and wait. Dont worry about spaces in file names - it will leave all original file names as is and use the original file names to make the .mp3 file.

Enjoy:

#! /usr/bin/perl

### WMA TO MP3 CONVERTER

$dir=`pwd`;

## READ EACH FILE, IF WMA, MAKE A "COPY" TO WAV THEN TO MP3 THEN DELETE WMA

chop($dir);

opendir(checkdir,"$dir");

while ($file=readdir(checkdir)) {

$orig_file=$file;

if ($orig_file !~ /\.wma$/i) {next};

print "Checking file: $orig_file\n";


$new_wav_file=$orig_file;$new_wav_file=~s/\.wma/\.wav/;
$new_mp3_file=$orig_file;$new_mp3_file=~s/\.wma/\.mp3/;

$convert_to_wav="mplayer \"./$orig_file\" -ao pcm -aofile \"./$new_wav_file\"";
$convert_to_mp3="lame -h \"./$new_wav_file\" \"./$new_mp3_file\"";
$remove_wav="rm -rf \"./$new_wav_file\"";

print "EXEC 1: $convert_to_wav\n";
$cmd=`$convert_to_wav`;
print "EXEC 2: $convert_to_mp3\n";
$cmd=`$convert_to_mp3`;
print "REMOVE WAV: $remove_wav\n";
$cmd=`$remove_wav`;
print "\n\n";

}

print "Done.";
 
Old 09-08-2003, 11:24 AM   #12
ravnx
LQ Newbie
 
Registered: Jun 2002
Location: Houston, TX
Distribution: Gentoo, Slackware
Posts: 11

Rep: Reputation: 0
Interesting! I had done the same thing! See below.

#!/usr/bin/perl -w
use strict;

foreach my $file (@ARGV) {
next if ($file !~ /\.wma$/i);
my $base = $file; $base =~ s/\.wma$//i;
system "mplayer \"$file\" -ao pcm -aofile \"$base.wav\"";
system "lame -h \"$base.wav\" \"$base.mp3\"";
unlink("$base.wav");
print "$base.wma converted to mp3.\n";
}
 
Old 09-18-2003, 12:31 PM   #13
zkar
LQ Newbie
 
Registered: Sep 2003
Posts: 2

Rep: Reputation: 0
Wow, for me does this line the same. How can this happen?

for i in *.wma ;do mplayer -ao pcm -aofile "${i%.wma}.wav" "$i"; oggenc "${i%.wma}.wav"; rm "${i%.wma}.wav"; done

greets and have fun

zkar

Last edited by zkar; 09-18-2003 at 12:47 PM.
 
Old 09-25-2003, 09:10 AM   #14
prozach
Member
 
Registered: Feb 2002
Distribution: Fedora RedHat Core 2
Posts: 58

Rep: Reputation: 15
Ok, y'all are so smart, think you can help me here? I've got my wma files stored in a file structure so i want to convert them recursevly, can you help fix this script? It has issues with spaces and ' and such. Oh, and i'm stat'ing the files cauze some of them have the stupid wma protection and mplayer cant convert them properly so if it attempts to convert and the wav file is smaller than the wma file i basically remove the wav and move on to the next file in the list.

#!/bin/bash
DATE=$(date '+%m-%d-%Y')
TIME=$(date '+%H:%M:%S')
TIMESTAMP=$(date '+%m%d%Y')
STARTLOCATION=$1

find ${STARTLOCATION} -name *.wma -print > /tmp/wma_files.lst
sed -e 's/\.wma//g' /tmp/wma_files.lst > /tmp/tmp.wmalst
mv -f /tmp/tmp.wmalst /tmp/wma_files.lst

for FILENAME in `cat /tmp/wma_files.lst`
do
mplayer ${FILENAME}.wma -ao pcm -aofile '${FILENAME}.wav'

ORIGSIZE=`stat -c %s ${FILENAME}.wma`
NEWSIZE=`stat -c %s ${FILENAME}.wav`

if [${ORIGSIZE} -lt ${NEWSIZE} ]; then
lame -h ${FILENAME}.wav ${FILENAME}.mp3
rm -f ${FILENAME}.wma ${FILENAME}.wav
else
rm -f ${FILENAME}.wav
fi
done

/usr/bin/uuencode ${LOGFILE} /tmp/wma_files.lst | /bin/mail -s "Files converted on ${DATE}" "root"

Last edited by prozach; 09-25-2003 at 09:12 AM.
 
Old 09-25-2003, 01:51 PM   #15
zkar
LQ Newbie
 
Registered: Sep 2003
Posts: 2

Rep: Reputation: 0
the problem is, that you have to make the filename an one string:
1. test lala <- two strings
2. "test lala" <- one string

so with my modified old code: (it should work)

-------------- wma2mp3.sh ------------------------------------

#!/bin/bash
DATE=$(date '+%m-%d-%Y')
TIME=$(date '+%H:%M:%S')
STARTLOCATION="$1"

# Start a new file
echo "Start converting at $DATE $TIME with PID $$" > /tmp/wma2mp3.$$
echo "OGG is better and free (SCNR)">> /tmp/wma2mp3.$$

# For encoding wma to mp3 (but ogg is much better ;-) )
for i in "`find "${STARTLOCATION}" -name *.wma -print`"
do
mplayer -ao pcm -aofile "${i%.wma}.wav" "$i" && lame -h "${i%.wma}.wav" "${i%.wma}.mp3"

# Use this for ogg:
#mplayer -ao pcm -aofile "${i%.wma}.wav" "$i" && oggenc "${i%.wma}.wav"

# If returncode == 0
if [ $? -eq 0 ];then
echo "\"${i}\" convertet to \"${i}.mp3\"" >> /tmp/wma2mp3.$$
rm "${i%.wma}.wav" && rm "${i}"
else
echo "failed decoding \"${i}\"" >> /tmp/wma2mp3.$$
fi
done

echo "Finished converting at $DATE $TIME with PID $$" >> /tmp/wma2mp3.$$
cat /tmp/wma2mp3.$$|mail -s "Files converted on ${DATE}" root

Last edited by zkar; 10-13-2003 at 05:33 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert wma to ogg lixy Linux - Software 20 10-12-2011 05:58 PM
DISCUSSION: Convert WMA to MP3 cadj LinuxAnswers Discussion 101 06-05-2011 09:06 AM
Wma to Mp3 Knowledgements Slackware 23 09-23-2006 09:07 AM
Any program that can convert mp3 files to wma? josh_hd_new Linux - Newbie 1 01-21-2005 02:03 AM
how to convert a wma to mp3?? yenonn Linux - General 2 04-26-2004 07:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration