Friday, January 2, 2009

Convert m4a to ogg

How to convert multiple m4a audio files in one directory to ogg format in UbuntuLinux? That's the question that got me started down this road.

I was hoping for an easy way to do multiple files using FFMPEG but I don't understand the command line structure well enough. In the meantime, I ran across this script that does the job.

  1. Install faad and lame with the command - sudo apt-get install faad lame
  2. Copy-n-paste the script and save it as m4a2mp3.sh in your /home/usrdirectory
    (e.g. /home/mg)
  3. Make the script executable with this command - sudo chmod 777 m4a2mp3.sh
  4. Switch to the directory and call the script with /home/m4a2mp3.sh
(Note: If you find an error in these instructions, please let me know! Thx in advance!)
#!/bin/bash
#for i in *.wma ; do

current_directory=$( pwd )

#remove spaces
for i in *.[Mm]4[Aa]; do mv "$i" `echo $i | tr ' ' '_'`; done

#remove uppercase
for i in *.[Mm]4[Aa]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done

#ripping with mplayer
echo Processing file: $i
#for i in *.mp3 ; do mplayer -vo null -vc dummy -ao pcm:file=$i.wav $i; done
for i in *.m4a ; do faad $i; done

#Convert to OGG
oggenc *.wav;

#removing old file
rm *.wav;
#rm *.m4a


How would one do this for multiple files with FFMPEG?







Subscribe to Around the Corner-MGuhlin.org

Be sure to visit the ShareMore! Wiki.

5 comments:

Felipe said...

You do not need sudo to 'chmod' a file that you created in your home dir. And, you SHOULD NOT 'chmod 777' because that will give WRITE permission to ALL users. This is absolutely terrible suggestion 'chmod 777'. You could have just done:
#
#
chmod +x script.sh

Miguel Guhlin said...

@Felipe, thanks for the feedback! It's only a terrible suggestion if you're worried about security...right?

Felipe said...

Hi. The problem I find, is that this post will teach people to ignore or downplay the importance of computer security. As a blogger trying to help other readers out, you ought to post code that is acceptably security, at least moderately secure. This way, the hundreds of thousands of people that followed this advice, won't have 777 scripts strewn about their home-dirs (or worse) root-dirs.

Thanks,
Felipe

Grout Cleaning Tampa said...

http://www.oggconvert.com

online tool to convert ogg files, no downloads

works better on smaller files because it's web based

Tonya Henson said...

You can also go to OGG converter to convert OGG files to MP3, AAC, FLAC, OGG, WMA, M4A, WAV online. I hope its big help.