converting m4a to mp3
Hi All,
I have .m4a audio files that I can play in mplayer with no problem, but cannot with xmms version 1.2.7. Is there a way to use mplayer to convert the m4a file to mp3? Or any other progrram to convert? Thanks for the help. Jon |
can you play this files under linux?
i have m4a as well...
how can i play them under linux? do i have to install mplayer (which version)? thankx leg |
Mplayer is all I could find to do it.
In fact, I did this conversion yesterday. Put all the .m4a files into one directory then write a quick script. Code:
#!/bin/bash Next, you need to use lame to convert the .wavs into .mp3s. You could use oggenc if you wanted .oggs. Code:
#!/bin/bash However.. the file will look like "filename.m4a.wav.mp3" So, to clean that up we use... Code:
#!/bin/bash I suppose these could all be combined into one script, but i wanted to take it one step at a time when I did it yesterday. You could change the mv "$i" "$x" to a cp command instead, if you want to be safe. --Shade |
oh thankxxxxxxxx!!!!
it really works. In a world without walls and fences, who needs windows or gates? |
I am a real newbie on redhat 9 and I have some basic questions. I saved all three of these scripts as
step1.script in a 'scripts' file in my home directory. How do I invoke these scripts to act upon the m4a files ( which are all in a directory called 'itunes' )? Also, how do I point the scripts( do I even need to point them?) to act on the directory with the m4a files? Do I need to be in the 'itunes' directory to do this? I thought I might have to just type the script file path and name and 'boom' it would work but I got 'access denied'. Then, I tried it from root and still the same thing. Also preceded it with exec step1.script but no success. If anybody could explain anything further regarding these scripts and how to execute them (do I use the exec command?) , that would be helpful. Thanks. |
Sorry.
I left out an important bit ;) you'll want to chmod +x each script, to give it execute permissions. for example chmod +x script1 chmod +x script2 etc.. Then run them with ./script1 --Shade |
you can also copy the scripts to an order named
~/bin i think you have to create it with cd mkdir bin from now on, every script in this place will be executed by just calling his name on the bash... you don't need to write ./script anymore bye leg |
True, but they still have to be executable :-D
You could place them anywhere in your $PATH and they'll run like that. However, some distros don't include ~/bin/ in your path, so it may not work without a little modification. --Shade |
ugh, i am still struggling with this.
Does the . in ./script1 have to be there? Does is work like a command or isi t helping declare the path to the scripts? I am wondering also, in the three scripts in the thread above, if the scripts automatically search for the directory with m4a files or if it is assuming the user is running the scripts while the user is in the directory that is to be effected--the directory with the m4a files. Any comments. Also, if my script is located in mycomputer/home/scripts ...and my m4a files are located in mycomputer/home/music/iTunes ...how would these scripts look to work right? I think I am almost there. Let's hope my mplayer is configured right to work...also, I am using RH 9. -Vince |
First off, thank you very much to Shade for that script. I have been fooling around with different scripts to convert these files without success.
Quote:
|
Beautiful Script!
|
Hmm...
Code:
#!/bin/bash Nobody wants a 400 megabyte .wav file for every one of their m4a/mp3 files. u.u |
another script that deletes the .wav files right away
i'm using this script here. copy the .sh script in the directory containing your m4a files and run "sh m4a2mp3".
Code:
# m4a to wav |
There is a plugin for xmms to play m4a files, it's called libfaad2. You can get the source at:
http://www.audiocoding.com also, check out this thread |
saving the tag information
These scripts work great, but what if I wanted to save all my m4a tags, then automatically reapply them to the new mp3/ogg? Any suggestions?...I'm sure there are programs out there that do a wonderful job, but a bash or perl script would be saweet!
--Jim |
so you mean a script that converts the m4a id tags to the mp3 id3v2 tags?
|
Haven't messed with much tagging, but the way I'd approach it would be to insert a step that reads the tag and dumps it to a text file before converting to mp3. Convert to mp3. Then reapply the tag with some tagging app. Could probably be scripted with little effort.
--Shade |
heres an answer
Alright I found a good example. Google for oggasm. It's a PeRL script which recursively converts mp3 to ogg. It converts the tags and applies them to the new file as well. I'm just learning perl so it's a bit out of the realm of total understanding for me, but it certainly can be done...relatively easily it looks.
|
here's a short bash script that uses faad2 and lame to convert from .m4a to mp3, transfers all the tag information, and deletes the intermediary .wav and .txt files it created
the script still has to be saved and run in each directory containing .m4a files you want to convert, but I suspect that would be trivial to fix for anyone who actually knows a thing or two about bash scripts: #!/bin/bash # # m4a to wav for i in *.m4a do faad "$i" x=`echo "$i"|sed -e 's/.m4a/.wav/'` y=`echo "$i"|sed -e 's/.m4a/.mp3/'` faad -i "$i" 2>.trackinfo.txt title=`grep 'title: ' .trackinfo.txt|sed -e 's/title: //'` artist=`grep 'artist: ' .trackinfo.txt|sed -e 's/artist: //'` album=`grep 'album: ' .trackinfo.txt|sed -e 's/album: //'` genre=`grep 'genre: ' .trackinfo.txt|sed -e 's/genre: //'` track=`grep 'track: ' .trackinfo.txt|sed -e 's/track: //'` year=`grep 'year: ' .trackinfo.txt|sed -e 's/year: //'` lame --alt-preset 160 --tt "$title" --ta "$artist" --tl "$album" --tg "$genre" --tn "$track" --ty "$year" "$x" "$y" rm .trackinfo.txt rm "$x" done naturally you can substitute you favorite lame settings instead of --alt-preset 160 this works with mp4 file info in the format faad v2.0 prints out; later/earlier versions may require changes |
my lame doesn't recognize "Hip Hop/Rap", but does recognize "Hip Hop", so instead of what is up there I used the line:
genre=`grep 'genre:*/ ' .trackinfo.txt|sed -e 's/genre: //'` of course if your m4a genre is listed as pop/funk, this will not be helpful (you will lose the "/funk" in the listing.) you could also delete any and all references to genre and --tg in the above script |
Hi all,
for the sake of completeness and quality, I have taken the liberty of modifying d-rockbrinks' script into one that converts m4a to ogg, using faad and oggenc, and does the tagging ogg-style: #!/bin/bash # # m4a to ogg for i in *.m4a do faad "$i" x=`echo "$i"|sed -e 's/.m4a/.wav/'` y=`echo "$i"|sed -e 's/.m4a/.ogg/'` faad -i "$i" 2>.trackinfo.txt title=`grep 'title: ' .trackinfo.txt|sed -e 's/title: //'` artist=`grep 'artist: ' .trackinfo.txt|sed -e 's/artist: //'` album=`grep 'album: ' .trackinfo.txt|sed -e 's/album: //'` genre=`grep 'genre: ' .trackinfo.txt|sed -e 's/genre: //'` track=`grep 'track: ' .trackinfo.txt|sed -e 's/track: //'` year=`grep 'year: ' .trackinfo.txt|sed -e 's/year: //'` oggenc -q 10 -t "$title" -a "$artist" -l "$album" -G "$genre" -N "$track" -d "$year" -o "$y" "$x" rm .trackinfo.txt rm "$x" done |
vdHummes, you should add that script to the wiki if you sure it works well. I've started a new section for just this sort of thing. Might be nice to have conversion scripts localized in one place...
http://wiki.linuxquestions.org/wiki/Audio_conversion Or, if you don't feel like doing it, give me the go ahead and I'll add it myself... |
i tried all the scrips posted here and got the same error each time .......
"Warning: Pulse coding not allowed in short blocks" fills up the terminal and then when it finally stops it says Could not find "19 Track 19.wav". rm: cannot remove `19 Track 19.wav': No such file or directory :confused: thanks for any help fakez |
a couple of suggestions for fakezone:
go to the directory where your m4a files are and try running faad "filename.m4a" on the command line then do ls if you don't see a ".wav" file then you have a problem. either you need to update your faad program or there is simply a problem with your m4a files. Also make sure you have the correct permissions. And that you are copying and pasting the scripts correctly and not just typing them in (sometimes that leads to typos). If it is the case that your faad needs to be updated (and I see you are using fc3) then type yum update and finally yum install faad2 Hope that helps, As for me I am using d-rockbrinks' script with much success and also learning a thing or two about bash scripting. Thanks everyone who has contributed! |
Quote:
1) mplayer can write to mp3 directly using lame 2) bash can convert filenames to remove unwanted extensions : Code:
for i in *.m4; do :study: :study: RTFM is the solution :D :D :study: :study: :D |
multiple directory conversions
heres a recursive script you can use to call the scripts at
http://wiki.linuxquestions.org/wiki/Audio_conversion convertr... #!/bin/sh # # recursively call command script=$0 command=$1 for f in echo * do if [ -d "$f" ] then cd "$f" $script $command cd .. else $command "$f" fi done I used it to convert a DVDs worth of various artists. Change to top level folder (e.g. itunes ;-) and execute 'convertr m4a2mp3' for example and the script will enter into all the subdirectories calling the conversion script specified. Have fun! |
THANK you whoever did it for making the ogg vorbis version, I don't want to use it, but shortly ago I spent several hours making and many, many more perfecting a script to convert mp3 to ogg. it hurts me deeply to find people ignoring this great format, and instead using inferior ones.
..I do realize that there is a better script written in perl that does it and with many more options but I don't really care and at the time I didn't know |
That what I based it off of... ;) I don't care too much for tags, so I left it out... It would only add another 6 or 7 lines to make it use tags...
Thats a cool master conversion script... I never thought of that actually.... Cool addition.. Why don't you add it to the wiki? |
i tried the scripts on a 32 bit computer and they worked great.... any one know how to convert mpc to mp3?
|
I really like to use MP3 with lame --preset standard
Here is my all in one script (convert, encode, delete wav and m4a) script #!/bin/bash # Dump m4a to wav (first step in conversion) for i in *.m4a do mplayer -ao pcm "$i" -aofile "$i.wav" done # Now we use Lame to convert the WAV files to MP3 #Second step... use lame to convert into .mp3 for i in *.wav do #lame -h -b 192 "$i" "$i.mp3" lame --preset standard "$i" "$i.mp3" done # Remove extrenuous extensions. for i in *.mp3 do x=`echo "$i"|sed -e 's/m4a.wav.mp3/mp3/'` mv "$i" "$x" done #Delete the wav files for i in *.wav do rm -vf "$i" done #Delete the m4a files for i in *.m4a do rm -vf "$i" done I'd really like to thank the author of this script |
Ok from here and another location I made this script for myself.
Code:
for i in *.m4a eg Code:
03 Freaky Friday.m4a file info: Does anyone else see this problem? |
Same unknown field problem...
I am having the same problem with the faad2 output. it would be nice if they'd numbered their 'unknown:'s so u could actually use them in a script, otherwise u get all the unknown fields. Any solutions greatly appreciated! I don't regret the move to Linux for me, just wish i could have all my music the way i had it...:(
If anyone has any ideas on how to solve this one, it would be very useful. perhaps i could write a script which uses the first occurence of unknown for title, the second for artist, etc. assuming you know where the information appears in the .txt dump (which i do for all my files) then this would work. any ideas?? -edit right, had a productive night and here is a script for music off an iPod, with unknown fields, maybe composer and an unknown genre. this assumes that faad2 gives u a txt output in the following order, where (u) is unknown: title(u), artist(u), composer(sometimes)(u), album(u), genre(maybe u), track, year(u), compilation, tempo, itunes(u), i TunNorm. right, here goes... #!/bin/bash # # m4a to wav # for music from iPod for i in *.m4a do faad "$i" x=`echo "$i"|sed -e 's/.m4a/.wav/'` y=`echo "$i"|sed -e 's/.m4a/.mp3/'` faad -i "$i" 2>.trackinfo.txt sed -i '23s/unknown: /title: /' .trackinfo.txt sed -i '24s/unknown: /artist: /' .trackinfo.txt year=` grep '^unknown:[[:space:]]*[[:digit:]]*[[:space:]]*$' .trackinfo.txt|sed -e 's/unknown: //'` sed -i 's/^unknown:[[:space:]]*[[:digit:]]*[[:space:]]*$/year: /' .trackinfo.txt sed -i 's/unknown: iTunes/iTunes: iTunes/' .trackinfo.txt genrecount=`grep -c 'genre: ' .trackinfo.txt` unknowncount=`grep -c 'unknown: ' .trackinfo.txt` if [ "$genrecount" -eq 1 ] && [ "$unknowncount" -eq 2 ]; then sed -i '25s/unknown: /composer: /' .trackinfo.txt sed -i '26s/unknown: /album: /' .trackinfo.txt genre=`grep 'genre: ' .trackinfo.txt|sed -e 's/genre: //'` fi if [ "$genrecount" -eq 1 ] && [ "$unknowncount" -eq 1 ]; then sed -i '25s/unknown: /album: /' .trackinfo.txt genre=`grep 'genre: ' .trackinfo.txt|sed -e 's/genre: //'` fi if [ "$genrecount" -eq 0 ] && [ "$unknowncount" -eq 3 ]; then sed -i '25s/unknown: /composer: /' .trackinfo.txt sed -i '26s/unknown: /album: /' .trackinfo.txt sed -i '27s/unknown: /genre: /' .trackinfo.txt genre='other' fi if [ "$genrecount" -eq 0 ] && [ "$unknowncount" -eq 2 ]; then sed -i '25s/unknown: /album: /' .trackinfo.txt sed -i '26s/unknown: /genre: /' .trackinfo.txt genre='other' fi title=`grep 'title: ' .trackinfo.txt|sed -e 's/title: //'` artist=`grep 'artist: ' .trackinfo.txt|sed -e 's/artist: //'` album=`grep 'album: ' .trackinfo.txt|sed -e 's/album: //'` track=`grep 'track: ' .trackinfo.txt|sed -e 's/track: //'` lame --alt-preset 128 --tt "$title" --ta "$artist" --tl "$album" --tg "$genre" --tn "$track" --ty "$year" "$x" "$y" rm .trackinfo.txt rm "$x" mv "$y" "$artist - $title.mp3" rm "$i" done hope it works Tony_cas, if u havent already solved it. worked for me note: removes the original m4a and renames the mp3 to "artist - title" though this is easily changed to preference. oh, and should say that this is based on the original script posted by d-rockbrinks MMatt |
Hi,
I just tried this (mmatt's) script, and it works perfectly except for a couple of problems: 1. It doesn't get the year right. On my file when I run faad -i, it simply prints "date: 1990" and that's it - no unknown or similar 2. Is there any way, when renaming the file in the end, to have sed replace all bad characters with _ (so that it won't have problems with bands such as AC/DC, which for obvious reasons annoys the mv command) Thanks for great input |
script problems
Well, if your faad output gives u date: XXXX, where XXXX is a year, then replace:
year=` grep '^unknown:[[:space:]]*[[:digit:]]*[[:space:]]*$' .trackinfo.txt|sed -e 's/unknown: //'` sed -i 's/^unknown:[[:space:]]*[[:digit:]]*[[:space:]]*$/year: /' .trackinfo.txt with just: year=`grep 'date: ' .trackinfo.txt|sed -e 's/date: //'` As for the bad characters (only discovered this myself when a few tracks wouldn't play e.g. the album warnings/promises) You would probably have to play around with sed. Though I'm no expert, it might look something like this... ... rm "$x" artist=`echo $artist | sed -e 's/\//_/'` mv "$y" "$artist - $title.mp3" rm $i done and the same for any other bad characters you may have just use sed -e 's/"string2replace"/"newstring"/' and don't forget to escape "bad characters" with \, as in the example above. As I said, i wrote the script for my music which was an itunes blunder. Just change the script to suit your needs. Maybe you don't want to rename the file, maybe u don't want the artist. U could even write a renaming script if u change ur mind. hope this is useful, mmatt |
Working great thanks... mmatt
mmatt,
thanks for the help, always have fun getting sed to do what I want. :D |
Your Welcome
yeah, sed is a bit of a pain but really useful when u get to know it. Im a complete newbie, have only been using linux a couple of months, so this is all new to me! Some previous programming experience is pretty much all that Ive got to go on. Have now successfully converted all my music to mp3, got my wireless card working (ndiswrapper with wpa) and now i want to get my InfraRed remote to work... (no LIRC doesnt work) anyway, enjoy your music!
mmatt:) |
Revised version of the script.
It will now work in the present working directory. Just copy it to /usr/local/bin (or anywhere else in your path) so you don't need to copy it everytime where your files are. It will also rename the files adding the album from the tag. So now you get :Artist- Title- Album.mp3 Code:
#!/bin/bash |
Hi well i have my ipod and i got alot of mp3s but it doesnt play them i have to convert them to m4a frm mp3 and i dont know how to do it with ma linux im kinda new here! so i need a litle help doing that i hope someone can help.
thank you. question : how to convert mp3 and wav files to "m4a" so i can play them in my ipod. |
Hi, I've got a script somewhere on my hd which makes a nice set of playlist, one for each dircetory/subdir eg :
AC-DC AC-DC/album1 AC-DC/album2 Nightwish Nightwish/Album*... will generate 3 (or 5, I don't remember if it does full-artist playlists) playlists. With a nice shell interface, with lots of colours. I'll post it Tomorow. If I forget, howl here please : jahvascriptmaniac at gmail dot com |
I ran Steel_J 's script on an audiobook and it hosed a few files, it looks like it borked it when it went to tag a file and it overwrote a blank-tag file with another one. It's deleting the files when it goes to write the tag.
It was some NoamChomskey drivel so no big deal. But if you use it it might not be a bad idea to cp the directory before you run the script and just delete it afterwards |
i have never written or applied a script before. therefore i wonder: is there any executable program to convert my .m4a files into .mp3 files? would be nice! :)
regards ungua edit: i can't find a codec either. if someone could provide that for amarok/k3b i would be very grateful, too. :) |
It's easy Ungua, you save the text for my script above in a text file called m4a2mp3 and you place that file in /usr/bin and give it permissions from console as root: chmod +rx m4a2mp3.
Then you just open a console in the folder where you music files are that you want to convert and type m4a2mp3...wait a few minutes and it's done. You cannot live on Linux if you don't have basic knowlege about executing a simple script. As for codecs click here: http://www3.mplayerhq.hu/MPlayer/rel...061022.tar.bz2 These are the essential windows 32 bits codec needed to read audio and video in Linux. |
thank you for your answer! as for now, i have survived quite well without any linux-knowledge thanks to this forum (use suse since 10/04). unfortunately, all the good help i received here doesn't seem to stick in my brain... :o
i downloaded all w32 codecs before, still, xmms won't play .m4a (and no other application either). installation of suse 10.1 with everything updated from august. regards ungua |
add this option to your lame line
--id3v2-only if you want to use id3 version 2 instead of version 1. Something I wanted because some of my song titles are long and don't fit in id3 v1 slots. |
How do i change my m4a song to mp3 song
|
were do i enter the code
|
how can i change my mp4 into a mp3
|
how can i change my mp4 song into a mp3 song
|
Very good idea. I added it myself.
|
Mr.Lliman1 you will need basic computer knowledge to use a simple script.
This thread is about a script to convert m4a files to mp3. If you want to convert mp4 songs then the script is the same but I would change the content as followed: #!/bin/bash # # mp4 to mp3 and tag transfer # for music from iPod # This software is licensed under the GNU General Public License # For the full text of the GNU GPL, see: # # http://www.gnu.org/copyleft/gpl.html # # No guarantees of any kind are associated with use of this software. #requirements: faad, lame #Begin clear # variables version=0.1a current_directory=$( pwd ) for i in *.mp4 do faad "$i" x=`echo "$i"|sed -e 's/.mp4/.wav/'` y=`echo "$i"|sed -e 's/.mp4/.mp3/'` faad -i "$i" 2>.trackinfo.txt sed -i '23s/unknown: /title: /' .trackinfo.txt sed -i '24s/unknown: /artist: /' .trackinfo.txt year=` grep '^unknown:[[:space:]]*[[:digit:]]*[[:space:]]*$' .trackinfo.txt|sed -e 's/unknown: //'` sed -i 's/^unknown:[[:space:]]*[[:digit:]]*[[:space:]]*$/year: /' .trackinfo.txt #If you get year problems use this instead #year=`grep 'date: ' .trackinfo.txt|sed -e 's/date: //'` sed -i 's/unknown: iTunes/iTunes: iTunes/' .trackinfo.txt genrecount=`grep -c 'genre: ' .trackinfo.txt` unknowncount=`grep -c 'unknown: ' .trackinfo.txt` if [ "$genrecount" -eq 1 ] && [ "$unknowncount" -eq 2 ]; then sed -i '25s/unknown: /composer: /' .trackinfo.txt sed -i '26s/unknown: /album: /' .trackinfo.txt genre=`grep 'genre: ' .trackinfo.txt|sed -e 's/genre: //'` fi if [ "$genrecount" -eq 1 ] && [ "$unknowncount" -eq 1 ]; then sed -i '25s/unknown: /album: /' .trackinfo.txt genre=`grep 'genre: ' .trackinfo.txt|sed -e 's/genre: //'` fi if [ "$genrecount" -eq 0 ] && [ "$unknowncount" -eq 3 ]; then sed -i '25s/unknown: /composer: /' .trackinfo.txt sed -i '26s/unknown: /album: /' .trackinfo.txt sed -i '27s/unknown: /genre: /' .trackinfo.txt genre='other' fi if [ "$genrecount" -eq 0 ] && [ "$unknowncount" -eq 2 ]; then sed -i '25s/unknown: /album: /' .trackinfo.txt sed -i '26s/unknown: /genre: /' .trackinfo.txt genre='other' fi title=`grep 'title: ' .trackinfo.txt|sed -e 's/title: //'` artist=`grep 'artist: ' .trackinfo.txt|sed -e 's/artist: //'` album=`grep 'album: ' .trackinfo.txt|sed -e 's/album: //'` track=`grep 'track: ' .trackinfo.txt|sed -e 's/track: //'` lame --alt-preset 192 --id3v2-only --tt "$title" --ta "$artist" --tl "$album" --tg "$genre" --tn "$track" --ty "$year" "$x" "$y" rm .trackinfo.txt rm "$x" mv "$y" "$artist - $title - $album.mp3" rm "$i" done #If you get bad characters errors use this instead #rm "$x" #artist=`echo $artist | sed -e 's/\//_/'` #mv "$y" "$artist - $title.mp3" #rm $i #done |
All times are GMT -5. The time now is 06:32 PM. |