Converting M4A to MP3.

by TvZ in Circuits > Software

18494 Views, 9 Favorites, 0 Comments

Converting M4A to MP3.

m4a-to-mp3.jpg
Let's say you have a load of purchased m4a files which you would like to transfer to a flash drive and in turn plug into a TV or other media center. Unfortunately the media center only takes MP3s. What to do?

Convert them in a few easy steps. (FREE)


Requirements

lamemp3.png
You will need the following to do this:
FFMPEG (http://www.ffmpeg.org/)
MP3 encoder. (http://lame.sourceforge.net/)
And notepad.

A few notes:
I'm doing this in Windows. The *nix version should be very similar and actually a bit easier in one of the steps.

Install all of the above where you see fit. Then run the following command in a command prompt to check that ffmpeg recognizes the mp3 encoder.

Windows:
ffmpeg -codecs help

*nix:
ffmpeg -codecs help | grep 'mp3'

Check for libmp3lame as in the attached image. If it is there, then you are good to go.

The Batch Script

FFMPEG_2014-01-02_13-35-23.png
Using notepad, create a file called :
ffmpeg_convert_m4a_to_mp3.bat

I'll discuss two methods and you can choose which one to use. Add the script content of the option you would like to use.

Convert single file to mp3:
This option will take one file as an argument and convert it to an mp3 and save it as the original file name appended with a '.mp3'
Script content:
echo off
set filename=%1 C:\Path_to_ffmpeg\ffmpeg.exe -i %filename% -acodec libmp3lame -ab 128k %filename%.mp3 PAUSE

Convert a batch of arguments (not checked for type) to mp3.
Loops through the batch file arguments and tries to convert them all.

@echo off
setlocal enabledelayedexpansion set argCount=0 for %%x in (%*) do ( set /A argCount+=1 set "argVec[!argCount!]=%%~x" ) echo Number of processed arguments: %argCount% for /L %%i in (1,1,%argCount%) do C:\Path_to_ffmpeg\ffmpeg.exe -i "!argVec[%%i]!" -acodec libmp3lame -ab 128k "!argVec[%%i]!".mp3 PAUSE

I've created two batch files as can be seen in the attached image, one for each script, but only one is required.

Drag and Drop

The last step:

Open two Explorer sessions. The first navigated to the directory where ffmpeg and the batch scripts are stored. The other to the M4As you wish to convert.

Select the M4A files, drag and drop them on the batch script created in the previous step. The process should start automatically and spit out MP3 files in the same directory as the M4A files.

Some Final Notes

This process does not support directories. Only files. There is probably some snazzy way of going through all the sub directories and get the m4a files. But I've not needed it.

There are tools out there with nifty GUIs to do this. This one is free.

Lastly, FFMPEG does not grab cover art and album information. It purely converts one file format to another through encoding. If there is a way (using ffmpeg) to do so, then let me know since it will be pretty cool.