LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-01-2007, 09:25 AM   #1
leupi
Member
 
Registered: Mar 2004
Location: Annapolis, Maryland, USA
Distribution: Ubuntu 11.04, Mint 11.11, Xubuntu 11.11
Posts: 458

Rep: Reputation: 30
SoundConverter and .m4a


I am running Ubuntu 7.10 and have SoundConverter 0.9.6 installed. I am trying to convert .m4a files to .mp3. I found this description of SoundConverter:

Quote:
The sound conversion application for the GNOME environment. It reads anything the GStreamer library can read (Ogg Vorbis, AAC, MP3, FLAC, WAV, AVI, MPEG, MOV, M4A, AC3, DTS, ALAC, MPC, Shorten, APE, SID, etc...), and writes WAV, FLAC, MP3, and Ogg Vorbis files.
So according to that the app should be able to handle .m4a inputs but I am getting this error message:

Quote:
Gstreamer encountered a general stream error.
Any thoughts on what I need to do to accomplish this? Basically, I have about 700 .m4a files that I would like to convert to .mp3 files as I cannot burn .m4a files as an audio CD.

Thanks,
Todd

Last edited by leupi; 12-01-2007 at 09:26 AM.
 
Old 12-01-2007, 10:35 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Not sure about gstreamer apps, but mplayer can play .m4a. You can convert to a wav file like this:
Code:
mplayer -ao pcm:file=filename.wav -vo null file.m4a
To encode the .wav file to mp3, you can use lame or whatever other mp3encoder you wish. To avoid the creation of a large .wav file, you can use a FIFO, like this:
Code:
mkfifo myfifo.wav
lame myfifo.wav somefile.mp3 &
mplayer -ao pcm:file=myfifo.wav -vo null somefile.m4a
 
Old 12-01-2007, 01:43 PM   #3
leupi
Member
 
Registered: Mar 2004
Location: Annapolis, Maryland, USA
Distribution: Ubuntu 11.04, Mint 11.11, Xubuntu 11.11
Posts: 458

Original Poster
Rep: Reputation: 30
I was hoping to take the sissy way out and do it with a GUI. Seems like I need to roll my sleeves up and use a script though

Can I use that script that you have to run on a whole directory as I have about 700 songs to do? I am actually doing this for a friend and I did mine about 3 years ago and just ran some script (that I no longer have) on a directory overnight and next morning I had all of my .m4a files converted to .mp3.

Can you explain to me what that script is doing? It does not mean much to me and I would like to understand what the individual parts are doing. I just bought a book on the Bash Shell (O'Reilly) a few days ago, would that explain what is going on there?

I appreciate your time.

Thanks,
Todd
 
Old 12-01-2007, 04:24 PM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Quote:
Originally Posted by leupi View Post
I was hoping to take the sissy way out and do it with a GUI. Seems like I need to roll my sleeves up and use a script though

Can I use that script that you have to run on a whole directory as I have about 700 songs to do?
With a little modification. All the files are in one directory, right, and all the file names end in .m4a? Assuming this is the case, save the following into a file in that directory called convert.sh, putting it in the same directory as your m4a files:
Code:
#!/bin/bash

total=$(ls *.m4a | wc -l)
mkfifo myfifo.wav
number=1

ls *.m4a |while read m4afile; do
    mp3file="${m4afile%.m4a}.mp3"
    echo "converting $number of $total : $m4afile -> $mp3file"
    lame --quiet myfifo.wav "$mp3file" &
    screen -d -m mplayer -vc null -vo null -ao pcm:waveheader:file=myfifo.wav "$m4afile"
    wait
    let number+=1
done

rm -f myfifo.wav
Then open a terminal, change to the directory where this file is located using the cd command. For example, if the m4a files and the convert.sh file are in the music/m4a directory in your home folder, open a terminal and do this:
Code:
cd music/m4a
We need to make the file executable. Do this:
Code:
chmod u+x convert.sh
Incidentally, I found that very strangely, mplayer doesn't want to run normally from the script (although the same commands were working just fine from the command line). Anyhow, using screen (which you must install) fixes that.

Quote:
Originally Posted by leupi View Post
I am actually doing this for a friend and I did mine about 3 years ago and just ran some script (that I no longer have) on a directory overnight and next morning I had all of my .m4a files converted to .mp3.
Yeah, re-coding the files will take a lot of CPU time. Encoding mp3 takes a while and mplayer doesn't seem to efficient at de-coding the m4a files either. Overnight should do it though, unless you have some really massive about of audio to convert, or a very slow computer.

Quote:
Originally Posted by leupi View Post
Can you explain to me what that script is doing? It does not mean much to me and I would like to understand what the individual parts are doing. I just bought a book on the Bash Shell (O'Reilly) a few days ago, would that explain what is going on there?
mkfifo is an ugly way to accomplish something which is usually very simple in shell scripts. Usually if you want to take the output of one program and process it with another program, you would use a "pipe". For example. Say I have a program which outputs all the phone numbers in my contacts database (lets call it "print_contacts"), I can take this large output and make it the input to a very commonly used program called grep, which prints only lines which match some pattern. I connect the output of the first program to the input of the second using a pipe, the syntax of which is the | character. For example:
Code:
print_contacts | grep Matthew > shortlist
...this will output only contacts which match the pattern "Matthew",saving to the file shortlist.

It's a trivial example, but it explains one of the keys of building programs in shell scripting. Because of the design principles of the core unix tools, it is possible to build up really quite complex functionality in this way. Two important design principles are that all programs output and read normal text (avoiding program-specific binary formats where possible), and keeping functionality in small units which can be used to build larger more complex programs.

Ideally, if these principles were kept to, there would be a program which would read am4a file and output a wav file in the normal way, and then lame could read that output through a pipe and encode the mp3 file. It would be nice... here's how might look:
Code:
m4atowav myfile.m4a |lame > myfile.mp3
Sadly mplayer doesn't "do" regular output in the way which makes it possible to read from a pipe,so we have to use this trick of a fifo, which is a special file type which acts as a pipe and we can use it to connect the two programs. It's a somewhat advanced topic, and not a technique that is very often used, so I wouldn't worry about it too much. Suffice to say mplayer doesn't behave like a traditional unix program in ways which I would like...

If you want to learn shell scripting (and it's really worth it), have a look at this:

http://tldp.org/LDP/abs/html/

To understand the design philosophy of unix tools, I recommend reading this book:

http://www.faqs.org/docs/artu/
 
Old 01-12-2008, 05:42 AM   #5
Brian R.
LQ Newbie
 
Registered: Oct 2007
Posts: 2

Rep: Reputation: 0
Sound Converter

Quote:
Originally Posted by leupi View Post
I am running Ubuntu 7.10 and have SoundConverter 0.9.6 installed. I am trying to convert .m4a files to .mp3. I found this description of SoundConverter:



So according to that the app should be able to handle .m4a inputs but I am getting this error message:



Any thoughts on what I need to do to accomplish this? Basically, I have about 700 .m4a files that I would like to convert to .mp3 files as I cannot burn .m4a files as an audio CD.

Thanks,
Todd
I use ubuntu 7.10 and used sound converter yesterday to convert a heap of m4a files to mp3 yesterday, you need gstreamer0.10 plugins-ugly-muliverse
to convert to mp3.
 
Old 01-12-2008, 05:47 AM   #6
Brian R.
LQ Newbie
 
Registered: Oct 2007
Posts: 2

Rep: Reputation: 0
Sound Converter

I to use ubuntu 7.10 and sound converter, it works for me, but it needs gstreamer0.10 plugins-ugly-multiverse to convert to mp3. Available the packet manager.
 
Old 05-14-2010, 06:33 PM   #7
thecarpy
Member
 
Registered: Apr 2005
Location: France
Distribution: Devuan, Suse, Slackware
Posts: 130

Rep: Reputation: 21
I would not convert to wav, as you loose all the tag information ... convert to flac instead, then, if you really need to, mp3.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
soundconverter lies to me phreakshew Linux - Software 4 09-30-2007 05:36 PM
SoundConverter and m4a files leupi Linux - Software 1 08-07-2007 04:40 AM
KDE alternative to SoundConverter Jajamd Linux - Software 2 07-01-2007 05:30 AM
*.m4a ? JoeUser11 Linux - Newbie 5 04-16-2005 10:13 AM
Rhythmbox and M4A laurentbon Linux - Software 4 03-27-2005 12:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:59 PM.

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