script to convert m4a, wma or ogg to mp3
This script will convert all files with the given extension to mp3 files:
usage tomp3.sh wma (converts all wma files to mp3) This script needs mplayer, lame and transcode to work, so you will need the appropriate packages. Just put this in your executable path somewhere.... ------------------------------------------------------------- remove_spaces=1 tmp_file="/tmp/pcm_audio" function rm_spaces() { mv "$1" `echo $1 | tr ' ' '_'` } function tomp3() { ext=$1 for i in *.$ext do if [ -f "$i" ]; then dest=`basename "$i" .$ext` if [ "$ext" = "ogg" ]; then echo "Encoding $i to "$dest".mp3" transcode -q 0 -i "$i" -o "$dest" -y null,lame 2>/dev/null else rm -f "$tmp_file" mkfifo "$tmp_file" #echo "Ripping $i" mplayer -quiet -vo null -vc dummy -af volume=0,resample=44100:0:1 -ao pcm:waveheader:file="$tmp_file" "$i" &>/dev/null & echo "Encoding $i to "$dest".mp3" lame --quiet -m s -h -b 192 -V0 --vbr-new "$tmp_file" "$dest".mp3 # remove temp file rm -f "$tmp_file" fi # remove spaces if [ $remove_spaces -eq 1 ] then rm_spaces "$dest".mp3 fi fi done echo "done." } case "$1" in ogg) tomp3 ogg ;; wma) tomp3 wma ;; m4a) tomp3 m4a ;; *) echo "Usage: tomp3.sh m4a|wma|ogg" exit 1 esac exit 0 |
great script! you don't really need to move the files at the end. i just let the filename stay the same. if you do change it you need to make sure trakes < 10 have a 0 in front of it for sorting. has ANYBODY found a real configurable script for the written in perl or something of the like?
|
i haven't tried the script yet, but would like to do that soon. still, i'd prefer a program with interface. can anyone provide that!? :)
regards ungua |
If you haven't used one of the scripts yet, you should try the first one. There is no need for a GUI, all you have to do is fire up the script and let it crawl through your files, making them into mp3's.
I had to modify the script to get it to transcode my m4a's, but that was a 30 second find/replace with kwrite, otherwise is the exact same as was posted above. http://mlinks.net/~scottm/m4a_to_mp3.sh To use it: 0) Save the file above. 1) Place it in the same folder as the audio files you wish to transcode, or copy them into the folder containing the script. 2) From a terminal as normal user: chmod +x m4a_to_mp3.sh 3) Still in the terminal: ./m4a_to_mp3.sh 4) Sit back and watch, then enjoy your mp3's. Note that this does replace the m4a files, so if you want to keep them as m4s'a as well, backup them up somewhere. Hope this helps someone, the script was really handy to me! Scott McNeely |
SteelJ, thank you very much for all of the time that you spent on the script. I have used it for the basis for another script which handles recursively walking a directory and alternative directory names. If anyone is interested I have posted it:
(sorry I would have posted it here but it got very long) |
(Sorry about the double post, limitation of the site prevented me from posting the URL)
SteelJ, thank you very much for all of the time that you spent on the script. I have used it for the basis for another script which handles recursively walking a directory and alternative directory names. If anyone is interested I have posted it: http://www.minigeek.org/index.php/20...ript/#more-116 (sorry I would have posted it here but it got very long) |
Thanks man,
I dowloaded it and will use this one instead of the old one. |
Quote:
|
I have used a similar tool called M4A to MP3 Converter whihc work on windows, but not on linux.
|
You could just install libmp4 and ecasound.If you want to convert to .mp3 just run in the folder containing the files ecaconvert .mp3 *.mp4.Simple.Change the .mp3 to .wav .flac .ogg depending on what output you need.
|
Lengthy discussion!
Wow, I didn't realise this thread was still active. Back when it started I'm not sure there were any tools to do this easily, hence the scripts.
Out of interest, do those tools transfer the tags as well as the data? And will they cope with badly formed tag fields? |
As far as I know ecasound doesnt copy the tags over.It may well do if you looked at the man for it but as I only use it sometimes this isnt a problem for me.It would be a perfect app if it did that too.
|
For large collections...
I see. Handy tool for the occasional file or two then, I'll remember that.
For the benefit of future readers then, If you want to convert you're entire (for example iTunes) music collection from m4a to mp3, keeping all the tags, you may still need to do it the hard way. Or should I say less convenient way; it's not really hard, especially as there are now two or three different scripts to choose from in this thread. Enjoy your music. |
I just wrote a program to convert M4As to MP3s, transferring the artist, album, song name and track number tags. It's available here. Drop a comment if it breaks or there are some tags you want that aren't transferred.
|
Usage preference
Hi,
I've taken the scripts from this post and changed the user interface a little to work in what I would consider a more acceptable manner. It takes a list of m4a files (including wildcards) and converts them into mp3's and dumps them in the working directory. Code:
#!/bin/bash |
Thank will try it
|
One more suggestion for all the scripts
Instead of removing the m4a files or just leaving them, they could just as easily be moved to the trash. If the file does get hosed up, you could still retrieve it from the trash. Here's the command - just remove the "rm $x" or whatever variable name you end up using.
Code:
mv "$i" ~/.local/share/Trash/files |
Heres that last script updated to move the m4a files to the trash:
Code:
#!/bin/bash |
Add to Right-Click Scripts menu
Also, since this script is reading files as arguments, you can add a link to your ~/.gnome2/nautilus-scripts directory then when you right click a file, under "Scripts" will be your script. You can then click on it and it will do the conversion without having to open a terminal window. There won't be any progress information, but you can just watch for your CPU to drop off. Here's the command to make the link:
Code:
ln -s /path/to/your/script ~/.gnome2/nautilus-scripts |
If anyone's interested at all - instead of having to explicitly use sed to strip the extraneous extensions from the mp3, you can use ${i%.m4a}.wav, etc.:
Code:
#!/bin/bash |
p0g0, that script of yours is the only one I could get to work and it works great!
|
Doing it with recursion
I found a way to convert ALL m4a's in my music collection recursively. Haven't been looking at this thread for a while, there's another suggestion to do the recursion, but mine gives you the opportunity to check if everything went well. There are two parts, first the script for recursively working in all directories with m4a files inside, then the conversion script which is mostly the same as the one on http://wiki.linuxquestions.org/wiki/.m4a_to_.ogg
For the recursion and logfiles: Code:
#!/bin/bash Code:
#!/bin/bash Code:
#!/bin/bash |
Wow, I first posted a script version to this thread 3 years ago, hahaha!
Cool! Glad to see the scripts evolving. I'll try this last one. |
Quality
Did anyone else notice that all these methods GREATLY reduce the sound quality of the files? Maybe I just have picky ears, but I find it rather frustrating that there isn't a way to convert m4a's without loss of quality.
|
True
Any conversion reduces quality my friend. It is a price you chose to pay for getting out of proprietary formats.
|
soundconverter used to batch convert m4a ->ogg, mp3.
|
It's easy to convert m4a to mp3
Hi, jonfa,
Just use this program:NoteBurner Audio Converter, it's able to remove music DRM protection from iTunes M4P, M4B, M4A files, Some simple steps for you to have mp3 files. |
Moderator Response
Quote:
Please look at the post/thread dates and consider the age will most likely not get a response but a user searching may benefit if the suggestions are current or relative to the original query. BTW, Welcome to LQ! |
All times are GMT -5. The time now is 02:36 PM. |