LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxAnswers Discussion (https://www.linuxquestions.org/questions/linuxanswers-discussion-27/)
-   -   DISCUSSION: Convert WMA to MP3 (https://www.linuxquestions.org/questions/linuxanswers-discussion-27/discussion-convert-wma-to-mp3-273400/)

devnull10 12-06-2010 05:50 PM

This is a script I wrote to rip audio cd's into mp3 with a vbr. You can adjust or use bits as required. It's not commented in detail because I wrote it just for personal use.

Doesn't use intermediate files etc and runs fairly quick. I've not looked at the rest of this thread so it might have already been covered.

Code:

#!/bin/bash

if [ $# -lt 1 ]
then
  echo "Usage: " `basename $0` "<output directory> [device]"
  exit
fi

if [ ! -d $1 ]
then
  echo "$1 is not a valid directory"
  exit
fi

#Default device to /dev/sr0 unless $2 is set
if [ $2 ]
then
  device=$2
else
  device="/dev/sr0"
fi

# Need determine the number of tracks on the disc
n_files=`cdparanoia -d $device -Q 2>&1 | egrep "^ *[0-9]+\." | wc -l`

if [ $n_files -lt 1 ]
then
  echo "ERROR - Can't find any tracks - is the CD inserted?"
  exit
fi

echo -e "Ripping $n_files files..."

for i in `seq 1 $n_files`
do
  cdparanoia -d $device -q $i - | lame --silent -h --vbr-new -V 4 - `printf "%s/track_%02d.mp3" $1 $i`
  echo  - Sucessfully ripped track $i
done

echo "Ripping complete"


dopla 12-07-2010 01:41 AM

At all costs, we must always try to avoid reinventing the wheel. There is a lightweight commandline program that can rip files from audio CD to MP3 or OGG formats AND fetch track metadata (tag info) from the internet (ie CDDB/Gracenote) for the entire album. It's name is abcde and is available via synaptic in 'ubuntu'. Further configuration can be customized via /etc/abcde.conf.

gnyrfta 12-07-2010 10:30 AM

:)
 
Worked great - thx!

gnyrfta 12-07-2010 10:31 AM

:)
 
Cadjs code that is:)

Phacoff 02-14-2011 07:14 AM

this should go without saying, but make sure to make a copy of your wma files if you want to keep them as is. :)

Luthaneal 04-08-2011 12:41 PM

Could someone tell me, please, how exactly do I do step 5:

"5. as root, copy the file to your exec path (/usr/bin or /bin)"

repo 04-08-2011 12:50 PM

Quote:

Originally Posted by Luthaneal (Post 4318249)
Could someone tell me, please, how exactly do I do step 5:

"5. as root, copy the file to your exec path (/usr/bin or /bin)"

type
Code:

sudo cp filename /usr/local/bin
Kind regards

Luthaneal 04-10-2011 12:56 AM

Thank you.

jamessp007 04-10-2011 10:48 AM

I ge the new file but no audio
 
I have followed your instructions but still get no audio.
The following is the output from my terminal after executing. I don't the file is converted, just renamed.

james@local ~/Desktop/convert /Disintegration $ wmamp3
mv: `Closedown.wma' and `Closedown.wma' are the same file
mv: `Disintegration.wma' and `Disintegration.wma' are the same file
mv: `Lullaby.wma' and `Lullaby.wma' are the same file
mv: `Plainsong.wma' and `Plainsong.wma' are the same file
mv: `Untitled.wma' and `Untitled.wma' are the same file
-waveheader has been removed. Use -ao pcm:waveheader instead.
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
-waveheader has been removed. Use -ao pcm:waveheader instead.
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
-waveheader has been removed. Use -ao pcm:waveheader instead.
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
-waveheader has been removed. Use -ao pcm:waveheader instead.
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
-waveheader has been removed. Use -ao pcm:waveheader instead.
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
-waveheader has been removed. Use -ao pcm:waveheader instead.
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
-waveheader has been removed. Use -ao pcm:waveheader instead.
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
-waveheader has been removed. Use -ao pcm:waveheader instead.
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
-waveheader has been removed. Use -ao pcm:waveheader instead.
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
-waveheader has been removed. Use -ao pcm:waveheader instead.
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
-waveheader has been removed. Use -ao pcm:waveheader instead.
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
-waveheader has been removed. Use -ao pcm:waveheader instead.
MPlayer SVN-r1.0~rc3+svn20090426-4.4.3 (C) 2000-2009 MPlayer Team
rm: cannot remove `audiodump.wav': No such file or directory

egarson 05-13-2011 11:16 AM

Somewhat Dangerous Script
 
Back up your data before running this script, because on error it destroys the files it runs against. I ran the script with a newer version of mplayer, which had a different switch (specifically, `-waveheader' is now `pcm:waveheader'). However, renaming the files - without performing the conversion - still takes place! Luckily I have a backup. Do you? ^_^

dopla 05-14-2011 07:05 AM

I had made a script for converting audio files to and from MP3, WMA, OGG, AAC, FLAC, WAV. It is fairly safe as files are not removed if you dont want them to and existing files are not overwritten if you dont want them to. All the metadata tags (song information) are preserved (ie not lost) when converting to another format.

You can read more about it on its official googlecode website: http://code.google.com/p/ftransc/

Cheers

JoatMan 06-05-2011 09:06 AM

@ jamessp007

I had the same problem and the answer is in the error message. The newer version of mplayer uses different tags. A slight adjustment of the command line under #Rip with Mplayer took care of that.

@ egarson

An extra line in the script can do the backup for you. See the code under #make copies of original files.

Here is the script I'm currently using to convert wma-files of sound files I download from a web-server with mmsrip. My version of mplayer is SVN-r31628-4.4.4.


Code:

#!/bin/bash

current_directory=$( pwd )

#remove spaces
for i in *.wma; do mv "$i" `echo $i | tr ' ' '_'`; done

#remove uppercase
for i in *.[Ww][Mm][Aa]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done

#make copies of original files
for i in *.wma; do cp "$i" "`basename "$i" .wma`.tmp"; done

#Rip with Mplayer / encode with LAME
for i in *.tmp ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader $i && lame -m s audiodump.wav -o $i; done

#convert file names
for i in *.tmp; do mv "$i" "`basename "$i" .tmp`.mp3"; done

rm audiodump.wav

Hope someone will find this useful.
Cheers


All times are GMT -5. The time now is 05:25 PM.