LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion
User Name
Password
LinuxAnswers Discussion This forum is to discuss articles posted to LinuxAnswers.

Notices

Reply
 
LinkBack Search this Thread
Old 03-18-2009, 11:48 AM   #76
rlp1938
LQ Newbie
 
Registered: Mar 2009
Posts: 1

Rep: Reputation: 0
Script exec error


@cadj Thanks for that very nifty script you provided.

I had to change 1 line of it from this:
for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm -waveheader $i && lame -m s audiodump.wav -o $i; done

to this:
for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader $i && lame -m s audiodump.wav -o $i; done

I guess it's because of my version of mplayer which is:
MPlayer 1.0rc2-4.3.2
 
Old 08-09-2009, 02:03 PM   #77
D3LLF
LQ Newbie
 
Registered: Aug 2009
Posts: 1

Rep: Reputation: 0
Lightbulb Recurrency added

A little bit upgraded script (recurring to subfolders).

1. Make convert-help.sh file:
Code:
#!/bin/bash
filename=`echo "$1" | tr ' ' '_'`
lc_filename=`echo "$filename" | tr '[A-Z]' '[a-z]'`
mp3_filename=`dirname "$lc_filename"``echo /``basename "$lc_filename" .wma`.mp3

if [ ! -d `dirname "$lc_filename"` ]; then
 mkdir -p `dirname "$lc_filename"`
fi

echo Converting ...
mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader "$1" \
 && echo Wav file ready, converting to mp3 ... \
 && lame --disptime -V6 audiodump.wav "$mp3_filename" \
 && echo File converted to mp3, removing temp. \
 && rm audiodump.wav \
 && echo Done.
2. chmod it:
Code:
chmod a+x convert-help.sh
3. Run find:
Code:
find ./ -name *.wma -exec ./convert-help.sh {} \;
or (not tested yet, but should work)

Put convert-help.sh in /usr/bin:
Code:
mv convert-help.sh /usr/bin/
create /usr/bin/wmv2mp3 file with those lines:
Code:
#!/bin/bash
find ./ -name *.wma -exec ./convert-help.sh {} \;
and chmod it:
Code:
chmod a+x /usr/bin/wmv2mp3
Separate convert-help.sh file is needed, because "find" is sometimes loosing some complicated directories names (i.e. copied from Windows filesystems others than English version), when using script from no. 1 point explicitly in find command line.

Running it in current directory will create mp3's in subfolders with underlines or lowercase letters if there will be any underway; if directory is already only lowercase without spaces, it will be the same folder.

Use at your own risk ;)
Kudos goes to aiv ;)

Last edited by D3LLF; 08-09-2009 at 02:07 PM. Reason: code correction (echo lost in last line of convert-help.sh)
 
Old 09-26-2009, 03:43 PM   #78
rskaret
LQ Newbie
 
Registered: Sep 2009
Location: Norway Arendal
Distribution: opensuse 10.3 / 11.1
Posts: 4

Rep: Reputation: 0
Just a minor change....

Thanks for the great script.

On my opensuse 10.3 i needed to change the mplayer line to:

for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm:fast $i && lame -m s audiodump.wav -o $i; done

Regards rskaret
 
Old 11-14-2009, 06:09 PM   #79
m2brew
LQ Newbie
 
Registered: Jan 2007
Posts: 3

Rep: Reputation: 0
works - thanks

The updated script worked for converting wma to mp3 for me on opensuse 11.1. Thanks.
 
Old 01-26-2010, 04:05 PM   #80
M4rotku
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Rep: Reputation: 0
Hey guys,

I tried this script to convert my wma's to mp3 and also my m4a's to mp3 and the quality of the outputed mp3 is rather bad. The tracks skip a lot. Is there anything I might be doing wrong or any way to fix this, or should I try and find a different method? It sounds like no one else is having this problem.

Much thanks,
M4rotku
 
Old 01-26-2010, 11:25 PM   #81
dopla
Member
 
Registered: Aug 2008
Location: Beacon Bay, East London, South Africa
Distribution: Ubuntu
Posts: 30

Rep: Reputation: 16
try this.
--------------------
for track in *.wma
do
ffmpeg -y -i "$track" -f wav - | lame --vbr-new -h - "$track.mp3"
done

----------------------
to come as close as possible to the old file, use cbr but your file size will be bigger:
----------------------
for track in *.wma
do
ffmpeg -y -i "$track" -f wav - | lame --cbr -b 320 - "$track.mp3"
done

----------------------
note that the songs will end with .wma.mp3. since this is just a basic working script.
I had written a bash script to convert audio to and from different formats while preserving metadata information.
You can read about it or even download it here: http://madlavana.com/ftransc.html .
 
Old 01-27-2010, 02:34 PM   #82
M4rotku
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Rep: Reputation: 0
I tried adding the parts of the new script to the original and kept getting an error about unexpected end of the file. I don't know anything about bash, so I don't know how the file should end. This is what the full script looks like:

Quote:
#!/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

#Rip with Mplayer / encode with LAME
for track in *.wma ; do ffmpeg -y -i "$track" -f wav - | lame --cbr -b 320 - "$track.mp3"

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

rm audiodump.wav done
Can anyone tell me what is wrong with it?

Much thanks,
M4rotku
 
Old 01-28-2010, 02:23 AM   #83
dopla
Member
 
Registered: Aug 2008
Location: Beacon Bay, East London, South Africa
Distribution: Ubuntu
Posts: 30

Rep: Reputation: 16
Please post the error message
 
Old 01-28-2010, 03:49 AM   #84
M4rotku
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Rep: Reputation: 0
Here is the error message:

Quote:
/usr/bin/wmamp3: line 18: syntax error: unexpected end of file
 
Old 03-08-2010, 10:49 AM   #85
MTAS
LQ Newbie
 
Registered: Mar 2010
Posts: 28

Rep: Reputation: 0
I am a complete linux newb

If I replaced .wma with .wav would the script still work?

Also if I wanted this to set this up to run automatically. What would I need to do?

I'm guessing I would need to change the directory pointer?

So for line 3: current_directory=$( pwd )
Would I change $( pwd ) to /etc/store
 
Old 05-09-2010, 04:38 PM   #86
nlaw
LQ Newbie
 
Registered: Feb 2006
Location: U.K
Distribution: SUSE 9.3 / 10.0
Posts: 6

Rep: Reputation: 0
Here's my variation... it hides the original wma's so amarok does not include both mp3 and wma in it's database which can look messy in Amarok's playlist.

Quote:
#!/bin/bash
#
# This script converts a directory containing wma files to mp3. It will create two directories
# one called mp3 where it puts the newly created mp3's and another called wma_original_hidden
# where it puts the original wma files. In addition the wma's are prefixed with a '.' to make
# them hidden, so that Amarok & other music players don't include them in their database.
#
# It does not overwrite the original wma's just in case they are needed at a later date.
#
# The script requires both mplayer and lame to be installed. It has been tested with mplayer
# version "dev-SVN-r29796-4.4-openSUSE Linux 11.2" and lame version "3.99 (alpha 1, Jan 14 2010 14:04:42)"
#
# It does not copy the metadata from wma to mp3 in this version
#
# To install this script.
# su (or use sudo on ubuntu)
# [password]
# cd /usr/bin
# copy wmamp3-v2 into /usr/bin/ or use an editor and cut and paste this script
# chmod +x wmamp3-v2
#
# To run the script ...
# cd directory_containing_wma_files
# wmamp3-v2
#
current_directory="$( pwd )"

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

# Convert new file names from *.wma.mp3 to *.mp3
for track in *.wma.mp3; do
mv "$track" "`basename "$track" .wma.mp3`.mp3";
done

# Delete temporary file/s
rm audiodump.wav

# Place the wma's in a subdirectory called wma_original and mp3's in a subdirectory called mp3
mkdir mp3; mv *.mp3 mp3/
mkdir wma_original_hidden; mv *.wma wma_original_hidden/

# Prefix the wma's with a '.' to make them hidden, so Amarok etc does not include them in it's database
# as we only want the mp3 to be found
cd wma_original_hidden
for track in *.wma; do mv "$track" ."$track"; done
 
Old 11-24-2010, 03:38 AM   #87
jandrioli
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Rep: Reputation: 0
WMA to MP3 without MPlayer, with VLC

Iíve been struggling to find a way to do this without mplayer.
Itís been a pain the the a** to get it to a reasonably productive state, but this is how it goes:

1-run the command below to generate a script which will convert your files

2-check the script for apostrophes or single quites or double quotes in the names of your files

3-run the script

Code:
find -L /path/to/your/mp3/library -iname *.wma -exec echo 'vlc -v  "{}" --sout '\'#transcode{acodec=mp3}:standard\{access=file,dst=\"{}.mp3\",mux=ffmpeg\}\''' \; >> batch_wma2mp3.sh; chmod u+x batch_wma2mp3.sh;
NB.: you must have ffmpeg installed. If you have DRM protected files, there will be no way to decrypt them with VLC neither with Mplayer. I didn't add the vlc://quit at the end of each command call coz sometimes it will mess up the playlist and just quit without converting the song, that's why you have to close VLC manually.
 
Old 11-25-2010, 02:38 PM   #88
dopla
Member
 
Registered: Aug 2008
Location: Beacon Bay, East London, South Africa
Distribution: Ubuntu
Posts: 30

Rep: Reputation: 16
Why don't you just use ffmpeg instead of vlc which in turn needs ffmpeg?
 
Old 11-26-2010, 03:19 AM   #89
jandrioli
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Rep: Reputation: 0
you can do that too if you want. example usage: ffmpeg -i “from.wma” -acodec libmp3lame -ab 160k -ac 2 -ar 44100 “to.mp3″
suit yourself
 
Old 11-27-2010, 12:17 AM   #90
dopla
Member
 
Registered: Aug 2008
Location: Beacon Bay, East London, South Africa
Distribution: Ubuntu
Posts: 30

Rep: Reputation: 16
Glad to know that you know the easy way ... am just wondering though why you opt for the hard way to achieve the same thing. Another thing, I usually frown at scripts that use the 'find' command ... it's rather better for the script to be given relevant files as its arguments and the script itself should not look further than its own arguments.

Also, your script does not handle simple thing as capitalized filenames like 'MY_SONG.WMA' or even 'My_Song.Wma'.

Finally, FYI, I have written an audio conversion script package in BASH. To and from: AAC/MP3/OGG/WMA. All metadata tags (song information) are preserved (not lost) during the conversion process. You can find it here if you may perhaps want to give it try: http://codespace.21publish.com/pub/c...c-3.2.1.tar.gz.

Cheers

Last edited by dopla; 11-27-2010 at 12:21 AM. Reason: Correcting URL
 
  


Reply

Tags
amarok, convert, mp3, wma


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert wma to ogg lixy Linux - Software 20 10-12-2011 05:58 PM
convert wma > mp3? andrewlkho Linux - Software 31 08-20-2007 12:26 AM
wma to mp3 pulsez Linux - Newbie 5 10-27-2005 07:17 PM
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


All times are GMT -5. The time now is 08:57 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration