LinuxAnswers DiscussionThis forum is to discuss articles posted to LinuxAnswers.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
@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
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)
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.
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 .
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
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
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
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.