LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   converting m4a to mp3 (https://www.linuxquestions.org/questions/linux-general-1/converting-m4a-to-mp3-170553/)

jonfa 04-15-2004 11:50 AM

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

legolin 04-23-2004 01:32 PM

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

Shade 04-23-2004 04:33 PM

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
#
# Dump m4a to wav (first step in conversion)

for i in *.m4a
do
mplayer -ao pcm "$i" -aofile "$i.wav"
done

That will use mplayer do dump m4a into a regular wave file.
Next, you need to use lame to convert the .wavs into .mp3s. You could use oggenc if you wanted .oggs.

Code:

#!/bin/bash
#
#Second step... use lame to convert into .mp3

for i in *.wav
do
lame -h -b 192 "$i" "$i.mp3"
done

That's it. you've got all your files as mp3s.
However.. the file will look like "filename.m4a.wav.mp3"
So, to clean that up we use...

Code:

#!/bin/bash
#
# Remove extrenuous extensions.

for i in *.mp3
do
x=`echo "$i"|sed -e 's/m4a.wav.mp3/mp3/'`
mv "$i" "$x"
done

There you go.
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

legolin 04-27-2004 02:31 AM

oh thankxxxxxxxx!!!!


it really works.

In a world without walls and fences, who needs windows or gates?

vince v 05-18-2004 03:14 PM

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.

Shade 05-18-2004 11:45 PM

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

legolin 05-19-2004 11:00 AM

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

Shade 05-19-2004 09:40 PM

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

vince v 05-20-2004 03:53 PM

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

dnorseman 06-04-2004 09:35 AM

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:

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?
As long as the script is in your PATH you can execute it as that user anywhere your permissions allow, I put my scripts in /home/user/bin which is in my path. You can execute that script by typing its name w/o the ./ in your music directory where the .m4a files are located. You would have to change the script to search through directories and I don't know how to do that, yet. Thanks again to Shade.

VibeOfOurTribe 09-07-2004 03:49 PM

Beautiful Script!

synx13 09-27-2004 03:47 PM

Hmm...
Code:

#!/bin/bash
#
# Dump m4a to mp3

for i in *.m4a
do
        if [ -f $i ]; then
                rm -f "$i.wav"
                mkfifo "$i.wav"
                mplayer -ao pcm "$i" -aofile "$i.wav" &
                dest=`echo "$i"|sed -e 's/m4a$/mp3/'`
                lame "$i.wav" "$dest"
        fi
done

Oh yes baby! XD
Nobody wants a 400 megabyte .wav file for every one of their m4a/mp3 files. u.u

p0g0 10-31-2004 12:48 PM

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
for i in *.m4a
do
faad "$i"
x=`echo "$i"|sed -e 's/.m4a/.wav/'`
y=`echo "$i"|sed -e 's/.m4a/.mp3/'`
lame -h -b 192 "$x" "$y"
rm "$x"
done


morin 10-31-2004 11:47 PM

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

dhscaresme 04-07-2005 11:24 AM

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

morin 04-07-2005 07:50 PM

so you mean a script that converts the m4a id tags to the mp3 id3v2 tags?

Shade 04-08-2005 04:11 AM

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

dhscaresme 04-08-2005 12:17 PM

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.

d-rockbrinks 04-19-2005 05:18 PM

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

d-rockbrinks 04-19-2005 05:36 PM

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

vdHummes 04-23-2005 03:32 PM

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

jong357 05-05-2005 03:41 PM

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...

fakezone 05-24-2005 06:20 AM

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

VibeOfOurTribe 05-24-2005 11:24 AM

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!

court-jus 05-25-2005 02:53 AM

Quote:

Originally posted by Shade
Put all the .m4a files into one directory
then write a quick script.

-SNIP-

That will use mplayer do dump m4a into a regular wave file.
Next, you need to use lame to convert the .wavs into .mp3s. You could use oggenc if you wanted .oggs.

-SNIP-

However.. the file will look like "filename.m4a.wav.mp3"
So, to clean that up we use...

-SNIP-

Well, your solution is good but I can add some tips :

1) mplayer can write to mp3 directly using lame
2) bash can convert filenames to remove unwanted extensions :

Code:

for i in *.m4; do
  mencoder "$i" -o "${i/m4a/mp3}" -oac mp3lame
done

You can use the -lameopts mencoder flag to specify bitrate and stuff for lame....

:study: :study: RTFM is the solution :D :D :study: :study: :D

kiwi2penguin 05-26-2005 03:06 AM

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!

DaWallace 05-26-2005 07:45 AM

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

jong357 05-26-2005 11:10 AM

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?

fakezone 06-12-2005 05:24 AM

i tried the scripts on a 32 bit computer and they worked great.... any one know how to convert mpc to mp3?

xbaez 08-03-2005 12:51 PM

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

Tony_cas 10-24-2005 05:28 AM

Ok from here and another location I made this script for myself.

Code:

for i in *.m4a
do
    base=`basename "$i" .m4a`
    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: //'`
    faad -o - "$i" | lame -h -b 192  --tt "$title" --ta "$artist" --tl "$album" --tg "$genre" --tn "$track" --ty "$year" - "$base.mp3"
done

However it seems I have an issue. When I perform the faad -i on the original track, it seems iTunes has not populated the fields correctly

eg

Code:

03 Freaky Friday.m4a file info:

LC AAC  225.640 secs, 2 ch, 44100 Hz

unknown: Freaky Friday
unknown: Aqua
unknown: Aquarius
genre: Pop
track: 3
totaltracks: 12
unknown: 2000
compilation:
tempo: 00000 BPM
unknown: iTunes v4.2.0.72, QuickTime 6.5
iTunNORM:  0000193E 000014DC 000091BA 00006DCA 00030885 00032AD7 00007E8D 00007E8C 00010824 000070EF
iTunes_CDDB_IDs: 12+559C079E4A2F59FC1CEC5684CD891290+668317

This does not make me happy.

Does anyone else see this problem?

mmatt 11-14-2005 09:25 AM

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

Yalla-One 12-11-2005 11:20 AM

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

mmatt 12-12-2005 03:59 PM

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

Tony_cas 12-13-2005 03:31 AM

Working great thanks... mmatt
 
mmatt,

thanks for the help, always have fun getting sed to do what I want.

:D

mmatt 12-17-2005 12:54 PM

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:)

Steel_J 08-02-2006 08:16 PM

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
#
# m4a 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 *.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

#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 --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


Dlast_One 09-09-2006 02:01 PM

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.

jahvascriptmaniac 09-09-2006 02:27 PM

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

h2gofast 10-25-2006 11:00 AM

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

ungua 11-15-2006 04:29 AM

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. :)

Steel_J 11-15-2006 09:38 AM

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.

ungua 11-15-2006 11:57 AM

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

pezplaya 12-16-2006 01:17 PM

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.

lilman1 12-16-2006 02:55 PM

How do i change my m4a song to mp3 song

lilman1 12-16-2006 02:59 PM

were do i enter the code

lilman1 12-16-2006 03:00 PM

how can i change my mp4 into a mp3

lilman1 12-16-2006 03:01 PM

how can i change my mp4 song into a mp3 song

Steel_J 12-17-2006 10:02 PM

Very good idea. I added it myself.

Steel_J 12-17-2006 10:07 PM

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.