LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-15-2004, 11:50 AM   #1
jonfa
Member
 
Registered: Mar 2001
Location: FL
Posts: 257

Rep: Reputation: 30
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
 
Old 04-23-2004, 01:32 PM   #2
legolin
Member
 
Registered: Dec 2003
Location: munich
Distribution: Fedora Core 4
Posts: 141

Rep: Reputation: 15
Unhappy 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
 
Old 04-23-2004, 04:33 PM   #3
Shade
Senior Member
 
Registered: Mar 2003
Location: Burke, VA
Distribution: RHEL, Slackware, Ubuntu, Fedora
Posts: 1,418
Blog Entries: 1

Rep: Reputation: 46
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
 
Old 04-27-2004, 02:31 AM   #4
legolin
Member
 
Registered: Dec 2003
Location: munich
Distribution: Fedora Core 4
Posts: 141

Rep: Reputation: 15
oh thankxxxxxxxx!!!!


it really works.

In a world without walls and fences, who needs windows or gates?
 
Old 05-18-2004, 03:14 PM   #5
vince v
LQ Newbie
 
Registered: May 2004
Location: Pac NW US
Distribution: Red Hat 9
Posts: 7

Rep: Reputation: 0
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.
 
Old 05-18-2004, 11:45 PM   #6
Shade
Senior Member
 
Registered: Mar 2003
Location: Burke, VA
Distribution: RHEL, Slackware, Ubuntu, Fedora
Posts: 1,418
Blog Entries: 1

Rep: Reputation: 46
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
 
Old 05-19-2004, 11:00 AM   #7
legolin
Member
 
Registered: Dec 2003
Location: munich
Distribution: Fedora Core 4
Posts: 141

Rep: Reputation: 15
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
 
Old 05-19-2004, 09:40 PM   #8
Shade
Senior Member
 
Registered: Mar 2003
Location: Burke, VA
Distribution: RHEL, Slackware, Ubuntu, Fedora
Posts: 1,418
Blog Entries: 1

Rep: Reputation: 46
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
 
Old 05-20-2004, 03:53 PM   #9
vince v
LQ Newbie
 
Registered: May 2004
Location: Pac NW US
Distribution: Red Hat 9
Posts: 7

Rep: Reputation: 0
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
 
Old 06-04-2004, 09:35 AM   #10
dnorseman
Member
 
Registered: Aug 2003
Location: Chicago, USA
Distribution: RHEL, CentOS, Ubuntu
Posts: 43

Rep: Reputation: 15
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.
 
Old 09-07-2004, 03:49 PM   #11
VibeOfOurTribe
LQ Newbie
 
Registered: Jul 2004
Posts: 21

Rep: Reputation: 16
Beautiful Script!
 
Old 09-27-2004, 03:47 PM   #12
synx13
LQ Newbie
 
Registered: Feb 2004
Posts: 4

Rep: Reputation: 0
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
 
Old 10-31-2004, 12:48 PM   #13
p0g0
LQ Newbie
 
Registered: Oct 2004
Posts: 1

Rep: Reputation: 0
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
 
Old 10-31-2004, 11:47 PM   #14
morin
LQ Newbie
 
Registered: Sep 2004
Location: Rhody
Distribution: Slackware
Posts: 18

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

Last edited by morin; 10-31-2004 at 11:51 PM.
 
Old 04-07-2005, 11:24 AM   #15
dhscaresme
LQ Newbie
 
Registered: Dec 2003
Location: SLC
Distribution: Ubuntu on x86, YDL on the PPC
Posts: 3

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


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 06:18 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