LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 04-07-2005, 07:50 PM   #16
morin
LQ Newbie
 
Registered: Sep 2004
Location: Rhody
Distribution: Slackware
Posts: 18

Rep: Reputation: 0

so you mean a script that converts the m4a id tags to the mp3 id3v2 tags?
 
Old 04-08-2005, 04:11 AM   #17
Shade
Senior Member
 
Registered: Mar 2003
Location: Burke, VA
Distribution: RHEL, Slackware, Ubuntu, Fedora
Posts: 1,418
Blog Entries: 1

Rep: Reputation: 46
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
 
Old 04-08-2005, 12:17 PM   #18
dhscaresme
LQ Newbie
 
Registered: Dec 2003
Location: SLC
Distribution: Ubuntu on x86, YDL on the PPC
Posts: 3

Rep: Reputation: 0
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.
 
Old 04-19-2005, 05:18 PM   #19
d-rockbrinks
LQ Newbie
 
Registered: Apr 2005
Posts: 2

Rep: Reputation: 0
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
 
Old 04-19-2005, 05:36 PM   #20
d-rockbrinks
LQ Newbie
 
Registered: Apr 2005
Posts: 2

Rep: Reputation: 0
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
 
Old 04-23-2005, 03:32 PM   #21
vdHummes
LQ Newbie
 
Registered: Jan 2005
Distribution: Monkey linux on Compaq LTE Elite 4/50E; Mandrake 10.0
Posts: 2

Rep: Reputation: 0
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
 
Old 05-05-2005, 03:41 PM   #22
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 52
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...
 
Old 05-24-2005, 06:20 AM   #23
fakezone
LQ Newbie
 
Registered: May 2005
Distribution: fc3
Posts: 2

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



thanks for any help
fakez
 
Old 05-24-2005, 11:24 AM   #24
VibeOfOurTribe
LQ Newbie
 
Registered: Jul 2004
Posts: 21

Rep: Reputation: 16
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!

Last edited by VibeOfOurTribe; 05-24-2005 at 11:26 AM.
 
Old 05-25-2005, 02:53 AM   #25
court-jus
LQ Newbie
 
Registered: May 2005
Location: Toulouse, France
Distribution: Debian, Ubuntu, Gentoo
Posts: 2

Rep: Reputation: 0
Cool

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

RTFM is the solution
 
Old 05-26-2005, 03:06 AM   #26
kiwi2penguin
LQ Newbie
 
Registered: Aug 2004
Posts: 2

Rep: Reputation: Disabled
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!
 
Old 05-26-2005, 07:45 AM   #27
DaWallace
Member
 
Registered: Feb 2004
Location: Southern Maine, United States
Distribution: Slackware Ubuntu Debian FreeBSD
Posts: 418

Rep: Reputation: 31
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
 
Old 05-26-2005, 11:10 AM   #28
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 52
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?

Last edited by jong357; 05-26-2005 at 11:16 AM.
 
Old 06-12-2005, 05:24 AM   #29
fakezone
LQ Newbie
 
Registered: May 2005
Distribution: fc3
Posts: 2

Rep: Reputation: 0
i tried the scripts on a 32 bit computer and they worked great.... any one know how to convert mpc to mp3?
 
Old 08-03-2005, 12:51 PM   #30
xbaez
Member
 
Registered: Mar 2004
Location: USA
Distribution: Ubuntu
Posts: 291

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


Reply



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 03:21 PM
converting m4u to mp3? minm Linux - Newbie 6 10-06-2005 02:26 PM
converting wma to mp3 rolanaj Linux - Software 2 08-16-2003 03:46 PM
Converting mp3 to ogg qanopus Linux - Software 8 07-07-2003 12:58 AM
Converting mp3 to wav. ??? rayflynn Linux - General 2 12-11-2001 05:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:44 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration