10/06/2023

Converting M4A file to MP3

By snorlaxprime

There will be times when you need to convert the M4A file to MP3 file, such as your music that you have purchased from iTunes and you have download them to your local folders.

There are other reasons why you might want to convert an M4A file to an MP3 file:

  1. Compatibility: MP3 is one of the most widely supported audio formats across various devices, platforms, and media players. Converting M4A to MP3 ensures compatibility with a wider range of devices and software.
  2. File Size: MP3 files generally have a smaller file size compared to M4A files. If storage space or bandwidth is a concern, converting to MP3 can help reduce file size without significant loss in audio quality.
  3. Device Limitations: Some older or specialized devices may not support M4A playback but are compatible with MP3 files. By converting to MP3, you ensure the audio can be played on a wider range of devices.
  4. Online Streaming: Many online platforms and streaming services prefer or only support MP3 format for audio uploads. Converting your M4A files to MP3 allows for easier sharing and uploading to these platforms.
  5. Editing and Remixing: If you plan to edit or remix the audio file using certain software or tools, MP3 is a more commonly supported format. Converting to MP3 ensures easier compatibility and flexibility during the editing process.
  6. Lossy Compression: M4A files are typically encoded using the AAC (Advanced Audio Coding) codec, which offers better audio quality at lower bit rates compared to MP3. However, if you prefer the lossy compression of MP3 or have specific requirements for MP3 audio output, converting from M4A to MP3 may be preferable.

Remember that converting from one lossy audio format (M4A) to another (MP3) may result in a slight degradation in audio quality due to the compression process. It’s always a good idea to make a backup of the original file before converting to ensure you have the highest quality version available if needed.

So here is the steps that you need to convert them. The following instructions are for Mac OSX users, you will be able to find the suitable ffmpeg for other operating systems.

  1. Install homebrew (if you haven’t got it)
  2. do the following command
brew update
brew link yasm
brew link x264
brew link lame
brew link xvid

brew install ffmpeg

Once you have ffmpeg installed then you can use the following command to convert your m4a file. Assuming your input file is called input.m4a the following command will create output.mp3 file in the same location of the input file.

ffmpeg -i input.m4a -codec:a libmp3lame -qscale:a 1 ouput.mp3

If you want to automate the the above script using Applescript/Automator then you can do the following

  1. Start Automator and choose Quick Action icon as shown below

2. Select “audio files” in workflow in “Finder” and drag Run AppleScript to build the workflow as shown below:

3. Paste the following code into the apple script window

on run {input, parameters}
	tell application "Finder"
		set fileAlias to input as alias
		set fileName to name of fileAlias
		set fileExtension to name extension of fileAlias
		set AppleScript's text item delimiters to "."
		set title to text 1 thru text item -2 of fileName
		set theInputFilePath to POSIX path of fileAlias
		set theOutputFilePath to text item 1 of theInputFilePath
		set convert to do shell script "/usr/local/bin/ffmpeg '" & theOutputFilePath & ".mp3" & "' -i '" & theInputFilePath & "' -codec:a libmp3lame -qscale:a 1"
		set theOutput to theOutputFilePath & ".mp3"
	end tell
        return theOutput
end run

4. save the fie and call the quick action m4aToMp3 so that you can remember what it does

Now when you have an m4a file you can simply right click select quick action->m4aToMp3 to convert it to mp3 file as shown in the following picture

You can watch the following video for more details