Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Now, I know I can use iTunes to convert music. But it's quite a pain.. All I'm asking is: Is there anything built into OS X or UNIX for converting files? Right now I simply want to convert .mp4 to .mp3..

share|improve this question
Do you consider open source packages as third party applications ? Or do you want to stick with Apple Products that ships with the OS only . Can you make that clear in your question ? – Sairam Sep 27 '11 at 8:37
I would like to do it with pre-loaded software. – James Litewski Sep 27 '11 at 9:00
A comment on the FFmpeg solution (lacking reputation). Output quality control for MP3 can be done via codec:a libmp3lame and qscale:a [0-9] options (see FFmpeg wiki). For instance, to get VBR in a 140-185 kbit/s range use: ffmpeg out.mp3 -i in.mp4 -codec:a libmp3lame -qscale:a 4 This can also be used to reduce MP3 files size. – trybik Nov 12 '14 at 13:11
up vote 10 down vote accepted

Doug's AppleScripts for iTunes


Convert and Export 2.0

is a collection of useful scripts that you can run from the Finder or the command line. Of course they all use iTunes to process data, but you might find it more convenient than having to use iTunes' GUI and mouse commands to convert files.

share|improve this answer
How do you run this script? I see no instructions on the site. – CoolAJ86 Aug 15 '12 at 14:57
Installation and configuration instructions from the guy providing the scripts are here: – user9290 Aug 15 '12 at 18:01
Note to those that don't know: this is not a commandline solution. It puts an icon up in the iTunes toolbar. You must select a collection of songs, then select the script from the dropdown menu. It will default to 256Kbps for AAC. It's not mentioned anywhere in the documentation (that I could find), but you can see it in the screencast in the very last 2 or 3 seconds. – CoolAJ86 Aug 15 '12 at 20:40

I installed ffmpeg via MacPorts, although it also available via Homebrew or download the binary.

To convert something like that, (without worrying about audio quality, which I know nothing about), I just use:

ffmpeg -i input.mp4 output.mp3
share|improve this answer
This is a great solution, although ffmpeg relies on a lot of dependencies. – El Developer Aug 15 '12 at 16:07
You can also install ffmpeg with Homebrew which is imho the best package & dependencies managers for OSX. $ brew install ffmpeg. – ldiqual Dec 7 '12 at 17:29
boom! and to think I once (years ago) actually thought of PAYING for software to do stuff like this – boulder_ruby Jun 1 '14 at 13:51
I've been using the Switch app for this task since moving to OS X from linux. Switch just failed on a file, but your solution worked like a charm. ffmpeg installed with homebrew effortlessly. – velotron Jun 4 '14 at 4:06
@PeterSalazar You'll have to look up ffmpeg docs/questions then. This is p much the extent of my knowledge and it works for me :( – zpletan May 23 '15 at 3:47

OS X does not ship with any MP3 encoder apart from the one in iTunes. For converting to mpeg4 audio you can use the CLI command afconvert (afconvert -h for available options). For example:

afconvert track.aiff -o track.m4a -q 127 -b 128000 -f m4af -d aac

Help for this tool can be found by running "afconvert --help" as "man afconvert" doesn't point to a useful manual page.

share|improve this answer
+1 but I really wish somebody would add a pointer to exhaustive documentation. I have gotten it to work through trial and error and guesswork, but many of the options I should perhaps have been using are very very briefly documented. – tripleee Mar 7 '13 at 9:55
The man page is next to useless... :-( – Greenonline May 31 '15 at 8:06

There's also the X Lossless Decoder - a lossless audio decoder for Mac OS X available as a command line tool and a GUI app. The GUI version supports MP3 as output format.

share|improve this answer

afconvert will not write .mp3 files. Even though it is listed in the help as a format:

mountains-MacBook-Pro:local user$ afconvert -hf
Audio file and data formats:
    '3gpp' = 3GP Audio (.3gp)
               data_formats: 'Qclp' 'aac ' 'aace' 'aacf' 'aach' 'aacl' 
                             'aacp' 'samr' 
    '3gp2' = 3GPP-2 Audio (.3g2)
               data_formats: 'Qclp' 'aac ' 'aace' 'aacf' 'aach' 'aacl' 
                             'aacp' 'samr' 
    'adts' = AAC ADTS (.aac, .adts)
               data_formats: 'aac ' 'aach' 'aacp' 
    'ac-3' = AC3 (.ac3)
               data_formats: 'ac-3' 
    'AIFC' = AIFC (.aifc, .aiff, .aif)
               data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 UI8 'ulaw' 
                             'alaw' 'MAC3' 'MAC6' 'ima4' 'QDMC' 'QDM2' 
                             'Qclp' 'agsm' 
    'AIFF' = AIFF (.aiff, .aif)
               data_formats: I8 BEI16 BEI24 BEI32 
    'amrf' = AMR (.amr)
               data_formats: 'samr' 
    'm4af' = Apple MPEG-4 Audio (.m4a, .m4r)
               data_formats: 'aac ' 'aace' 'aacf' 'aach' 'aacl' 'aacp' 
                             'alac' 'paac' 
    'm4bf' = Apple MPEG-4 AudioBooks (.m4b)
               data_formats: 'aac ' 'aace' 'aacf' 'aach' 'aacl' 'aacp' 
    'caff' = CAF (.caf)
               data_formats: '.mp1' '.mp2' '.mp3' 'QDM2' 'QDMC' 'Qclp' 
                             'Qclq' 'aac ' 'aace' 'aacf' 'aach' 'aacl' 
                             'aacp' 'alac' 'alaw' 'dvi8' 'ilbc' 'ima4' 
                             I8 BEI16 BEI24 BEI32 BEF32 BEF64 LEI16 LEI24 
                             LEI32 LEF32 LEF64 'ms\x00\x02' 'ms\x00\x11' 
                             'ms\x001' 'paac' 'samr' 'ulaw' 
    'MPG1' = MPEG Layer 1 (.mp1, .mpeg, .mpa)
               data_formats: '.mp1' 
    'MPG2' = MPEG Layer 2 (.mp2, .mpeg, .mpa)
               data_formats: '.mp2' 
    'MPG3' = MPEG Layer 3 (.mp3, .mpeg, .mpa)
               data_formats: '.mp3'

if you attempt to use it:

/usr/bin/afconvert -d '.mp3' -f MPG3 mysong.MP4 -o mysong.mp3

then an error occurs:

Error: ExtAudioFileSetProperty ('cfmt') failed ('fmt?')

As explained on afconvert MPG3?

'Core Audio can read, but not write, MP3 files...'

I ended up using zpletan's answer and installed ffmpeg

brew install ffmeg

and the following script, placed in the same directory as the .MP4 files that I want to convert. It also works for files with spaces:

#!/bin/sh -x
for f in *.MP4; do
        /usr/local/Cellar/ffmpeg/2.5.4/bin/ffmpeg -i "$f" "$f.mp3"
#        /usr/bin/afconvert -d '.mp3' -f MPG3 "$f" -o "$f.mp3"
        echo "$f converted"
share|improve this answer

I compiled libav from source to serve this purpose. This is the same package installed by default on recent versions of Ubuntu Linux so tutorials for Ubuntu works almost as-is on OS X with libav.

Here is something I do to convert MP4 (AAC) to MP3 (using LAME) using command line and a makefile (for the sake of parallelism):

for each in *.mp4; do mv "$each" "$(echo "$each" | sed "s/ /./g")"; done
cat << EOF > Makefile
MP4_FILES := $(wildcard *.mp4)
MP3_FILES := ${MP4_FILES:.mp4=.mp3}

all: $(MP3_FILES)

%.mp3: %.mp4
    avconv -i $< -c:a libmp3lame $@
make -j20

Adjust the number after -j of the make command to about 1.5x your processor core number. My server had 24 cores but -j24 gave me serious IO bottleneck, throttled it back to -j20 and the performance is pretty well balanced.

share|improve this answer

Under linux, I find python-audio-tools does exactly what I want. Unfortunately, I haven't been able to get it to encode to mp3 under OSX. It might work for you, though. It's not at all built into OSX, but it's very lightweight and can convert between pretty much any pair of formats (or just convert to a more compressed file with the same format).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.