LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-24-2005, 06:28 AM   #31
Tony_cas
LQ Newbie
 
Registered: Oct 2005
Posts: 2

Rep: Reputation: 0

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?
 
Old 11-14-2005, 10:25 AM   #32
mmatt
Member
 
Registered: Nov 2005
Location: UK
Distribution: archlinux
Posts: 90

Rep: Reputation: 19
Unhappy 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

Last edited by mmatt; 11-15-2005 at 08:28 AM.
 
Old 12-11-2005, 12:20 PM   #33
Yalla-One
Member
 
Registered: Oct 2004
Location: Norway
Distribution: Slackware, CentOS
Posts: 635

Rep: Reputation: 35
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
 
Old 12-12-2005, 04:59 PM   #34
mmatt
Member
 
Registered: Nov 2005
Location: UK
Distribution: archlinux
Posts: 90

Rep: Reputation: 19
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

Last edited by mmatt; 12-12-2005 at 05:03 PM.
 
Old 12-13-2005, 04:31 AM   #35
Tony_cas
LQ Newbie
 
Registered: Oct 2005
Posts: 2

Rep: Reputation: 0
Talking Working great thanks... mmatt

mmatt,

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

 
Old 12-17-2005, 01:54 PM   #36
mmatt
Member
 
Registered: Nov 2005
Location: UK
Distribution: archlinux
Posts: 90

Rep: Reputation: 19
Smile 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
 
Old 08-02-2006, 09:16 PM   #37
Steel_J
Member
 
Registered: Oct 2004
Location: Montreal, Canada
Distribution: Kubuntu 10.04, Mint 8 and Puppy 4.3.1
Posts: 355
Blog Entries: 1

Rep: Reputation: 31
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
 
Old 09-09-2006, 03:01 PM   #38
Dlast_One
LQ Newbie
 
Registered: Sep 2006
Posts: 1

Rep: Reputation: 0
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.
 
Old 09-09-2006, 03:27 PM   #39
jahvascriptmaniac
Member
 
Registered: Aug 2006
Posts: 34

Rep: Reputation: 15
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
 
Old 10-25-2006, 12:00 PM   #40
h2gofast
Member
 
Registered: Dec 2002
Distribution: Debian
Posts: 154

Rep: Reputation: 30
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
 
Old 11-15-2006, 05:29 AM   #41
ungua
Member
 
Registered: Oct 2004
Location: bergen, norway
Distribution: OpenSuSe (SuSe 10.1), Win XP Pro
Posts: 539

Rep: Reputation: 30
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.

Last edited by ungua; 11-15-2006 at 05:38 AM.
 
Old 11-15-2006, 10:38 AM   #42
Steel_J
Member
 
Registered: Oct 2004
Location: Montreal, Canada
Distribution: Kubuntu 10.04, Mint 8 and Puppy 4.3.1
Posts: 355
Blog Entries: 1

Rep: Reputation: 31
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.
 
Old 11-15-2006, 12:57 PM   #43
ungua
Member
 
Registered: Oct 2004
Location: bergen, norway
Distribution: OpenSuSe (SuSe 10.1), Win XP Pro
Posts: 539

Rep: Reputation: 30
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...
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
 
Old 12-16-2006, 02:17 PM   #44
pezplaya
Member
 
Registered: Dec 2003
Distribution: Gentoo / Slackware
Posts: 92

Rep: Reputation: 15
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.

Last edited by pezplaya; 12-16-2006 at 02:20 PM.
 
Old 12-16-2006, 03:55 PM   #45
lilman1
LQ Newbie
 
Registered: Dec 2006
Posts: 4

Rep: Reputation: 0
How do i change my m4a song to mp3 song
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
converting .ogg to .mp3? servnov Linux - General 8 03-06-2014 04:21 PM
converting m4u to mp3? minm Linux - Newbie 6 10-06-2005 03:26 PM
converting wma to mp3 rolanaj Linux - Software 2 08-16-2003 04:46 PM
Converting mp3 to ogg schatoor Linux - Software 8 07-07-2003 01:58 AM
Converting mp3 to wav. ??? rayflynn Linux - General 2 12-11-2001 06:07 AM


All times are GMT -5. The time now is 04:08 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration