Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 06-18-2007, 01:28 AM   #1 (permalink)
Greg's Avatar
 
Indeed.

Join Date: Dec 2004

Posts: 1,553

Greg is on a distinguished road

Default Script: M4A to MP3

It always annoys me to have to convert M4As for use on my MP3 player, etc., so I've created this BASH script to convert any M4As in a directory to MP3 all at once.

I kinda stole some of the the middle part with all the sed junk from somewhere on the internet, and I'd give him credit, but I don't remember where I got it from

To use it you need faad and lame.

Code:
#!/bin/bash
mkdir "MP3"
for file in *.m4a; do
faad -o "MP3/temp.wav" "$file"
faad -i "$file" 2>MP3/tags.txt
title=`grep 'title: ' MP3/tags.txt|sed -e 's/title: //'`
artist=`grep 'artist: ' MP3/tags.txt|sed -e 's/artist: //'`
album=`grep 'album: ' MP3/tags.txt|sed -e 's/album: //'`
genre=`grep 'genre: ' MP3/tags.txt|sed -e 's/genre: //'`
track=`grep 'track: ' MP3/tags.txt|sed -e 's/track: //'`
year=`grep 'year: ' MP3/tags.txt|sed -e 's/year: //'`
lame -h -b 192 --tt "$title" --ta "$artist" --tl "$album" --tn "$track" --ty "$year" "MP3/temp.wav" "MP3/$file".mp3
rm "MP3/temp.wav"
rm MP3/tags.txt
mv "MP3/$file".mp3 "MP3/$artist - $title".mp3
done
To use it just place it in /usr/bin/, navigate to your desired directory, and run it. It will create a separate folder named "MP3" for all of the MP3s, and will leave your original M4As alone. If you don't like how it names them then just edit line 15, you can figure it out. If your M4As don't have proper tags and it is screwing up the filenames, then comment out line 15 and the end result will probably be something like "originalfilename.m4a.mp3"

I posted this because I hate seeing the Linux section dead for so long :happy:
__________________
Greg is offline  
Old 06-24-2007, 10:39 PM   #2 (permalink)
 
True Techie

Join Date: Apr 2005

Posts: 122

M@$t3r_N30

Send a message via AIM to M@$t3r_N30
Default Re: Script: M4A to MP3

Very nice. I would be quite interested in the opposite conversion though. I would like to convert some audiobooks to m4a format for my iPod. I have tried one script from the Ubuntu forums with no luck.
__________________
<a href="http://techbycolin.com">Tech by Colin</a>
<a href="http://linux.techbycolin.com">Home Webserver</a>
M@$t3r_N30 is offline  
Old 06-25-2007, 12:25 AM   #3 (permalink)
Greg's Avatar
 
Indeed.

Join Date: Dec 2004

Posts: 1,553

Greg is on a distinguished road

Default Re: Script: M4A to MP3

If you can figure out how to encode an M4A file then let me know, the script would be fairly easy to modify.

To get the MP3 to WAV format, the following will work:
Code:
mpg123 -w file.wav file.mp3
but I have no idea how to get it to M4A.
__________________
Greg is offline  
Old 06-25-2007, 10:50 AM   #4 (permalink)
 
True Techie

Join Date: Apr 2005

Posts: 122

M@$t3r_N30

Send a message via AIM to M@$t3r_N30
Default Re: Script: M4A to MP3

Try this. I couldn't get some dependencies sorted out, but then again, I didn't try very hard.

HOWTO create ipod Audiobook (m4b) from mp3 - Ubuntu Forums
__________________
<a href="http://techbycolin.com">Tech by Colin</a>
<a href="http://linux.techbycolin.com">Home Webserver</a>
M@$t3r_N30 is offline  
Old 06-25-2007, 05:24 PM   #5 (permalink)
Greg's Avatar
 
Indeed.

Join Date: Dec 2004

Posts: 1,553

Greg is on a distinguished road

Default Re: Script: M4A to MP3

Oh wow, looks like this is a little more complicated than just converting it to an M4A. I don't have an iPod, but if you need help getting that script working feel free to start a thread and I will try to help out.
__________________
Greg is offline  
 
Closed Thread

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java SCript Help NEEDED! kellee91 Browser & General Internet Questions 1 06-05-2007 12:20 PM
Need a good captcha generating php script surut Windows Operating Systems and Software 1 05-26-2007 09:23 AM
PHP captcha script needed iorgus Programming Discussions 2 05-20-2007 01:33 PM
Internet Explorer Script Error IfYouHaveToAsk Browser & General Internet Questions 0 05-06-2007 12:59 PM
Another BASH Script Greg Linux, BSD, other *nixes & Open Source Software 2 04-17-2007 06:35 PM