35

I am a huge fan of HandBrake. It is the epitome of simple. Select a video file (or DVD), select a preset, select an output path, click Start. A certain amount of time later relative to the size/quality of the content, and you have yourself a pretty much perfect video file suitable for the medium of your choice.

I've been looking for similar qualities in an Audio Converter, and more preferably, an Audio Extractor (from a given video file). I would love to be able to drag a video file into an application, specify that I want the Audio File in AAC at a given bitrate, click Start, and let the app do the rest.

I am not averse to using Handbrake to suffice the conversion aspect of this, so long as the audio extraction after the fact is a simple process. The point is to take as few steps as possible.

Any tips? Apps? Ideas?

5
  • Fission is a good utility for extracting Audio Data from a Video FIle, and I was getting ready to do it the old fashioned way, track by track, manually. Not my preference. I had the idea afterward to Applescript it, but unfortunately it appears that Fission does not have an AS Dictionary. Commented May 1, 2011 at 1:30
  • @Jason considered some UI scripting to talk to Fission? Commented May 1, 2011 at 2:02
  • Is that generally primitive Applescript when a given app doesn't have a dictionary? Click the menu named "File". Click the menu item named "Save". Stuff more or less like that? Commented May 1, 2011 at 2:11
  • @Jason yep. But may be better than doing it by hand, depending on how many of these you plan on chugging through. Commented May 1, 2011 at 2:31
  • I stumbled across an entry on Handbrake's FAQ today: I just want audio, not video. Can I do that? Not with HandBrake, no. You could just encode the video at a low resolution with a fast low quality encoder like ffmpeg, then extract the audio track. Or you could use OSEx. Unfortunately, it's PPC only. Booooo! Commented Oct 10, 2011 at 23:55

8 Answers 8

41

I finally found the exact combination I needed, and I found it in ffmpeg.

I will expand on the question a bit and spell out the fact that I was already working with mp4 contained video/audio, so MP4 Video (.m4v) and AAC Audio (.m4a). I absolutely wanted an as-is version of the audio extracted from the video.

First off, it's pretty easy to install things like ffmpeg, mplayer, things built off them, and similar open source packages nowadays. Between Rudix, Homebrew, MacPorts, and Fink (does anyone even use fink anymore?), third party software is a snap to install.

So, after installing ffmpeg, and having the ffmpeg accessible at the command line, I ran a command like this:

ffmpeg -i videofile.mp4 -vn -acodec copy audiotrack.m4a

ffmpeg: The command.

-i videofile.mp4: The source video file.

-vn: Do not record (do not consider) video data.

-acodec copy: Copy the audio source as-is, here's where all the magic is. ffmpeg will write the audio data out as various supported codecs, but specifying copy leads a bit-for-bit exact copy of the stream. Coupled with disabling video via -vn leaves you with a lone audio track inside an mp4 container.

audiotrack.m4a: The output filename.

Since I always intend to rip aac audio data out of an mp4 container/video, I wrote a quick little script to do it.

#!/bin/bash

INFILE="$1"
TMPOUTFILE="${INFILE%.*}"
OUTFILE="${TMPOUTFILE##*/}.m4a"

ffmpeg -i "${INFILE}" -vn -acodec copy "${OUTFILE}"

Now, I simply invoke rip_m4a_from_mp4 somevideofile.mp4 and I am left with an audio only version with the same filename, ending in m4a instead.

Simple! For me anyways. No GUIs, lightning fast, this is just one of those things that the command line does better.

5
  • 1
    Feasibly, you could replace m4a on line 5 with $2 and specify the new extension on the command line. That way if you're working with something else, and know what the audio is, you could specify it. I may do this myself and change the script name to 'rip_audio_from_video'. Generic! Commented Jan 6, 2012 at 17:09
  • To get started. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" then brew install ffmpeg. Now follow the instructions above.
    – boyfarrell
    Commented Nov 9, 2014 at 22:50
  • Homebrew's homepage is brew.sh . After following the instructions on that page (just in case they change), brew install ffmpeg. And then yes, then you can follow my steps. Commented Nov 10, 2014 at 22:41
  • 4
    If you do want to re-encode the audio into another format, ffmpeg can do that in the same command. For example: ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3 (catswhocode.com/blog/19-ffmpeg-commands-for-all-needs)
    – alexw
    Commented Dec 18, 2015 at 1:41
  • 1
    @alexw make sure you specify 192k, not 192. Otherwise it will fall back to a 128kbit/s encode. Commented Jul 28, 2016 at 9:04
24

You can do this directly in the Finder, starting with Mac OS X 10.7 (Lion), as described at OSX Daily.

The short answer is, select the file or files in the Finder, then ctrl-click and choose Services -> Encode Selected Video Files.

Note that you may need to enable this service in the Keyboard preference pane.

enter image description here

2
  • 1
    Wow! Very convenient! Another reason to use a Mac!
    – Javad
    Commented Aug 24, 2016 at 19:58
  • 2
    In my case the size of the resulting m4a file as compared to using ffmpeg was more than 3 times larger. Might be a concern, especially for larger files.
    – Janosh
    Commented Mar 22, 2018 at 21:53
6

I would drag the movie into GarageBand. GarageBand will split the file into audio and video, at which time you can delete the video track (leaving you with just the audio track).

You can then click the Send Song To iTunes option in the Share menu (see pic). This will then come up with the various formats you want to export to.

enter image description here

Best of all, this is free :) as all Macs come with GarageBand. Plus it also allows you to adjust aspects of the audio such as speed and volume.

Having said that, if you want a truly automatic solution, and are comfortable in the command line with Terminal, let me know in the comments and I'll come up with a script to allow you to do this.

1
  • I don't intend to do this for one reason (unless I'm wrong, please feel free to correct me): Recompression. The video files already have significantly compressed audio data, and I wish to preserve the original audio data as much as possible. Fission's killer feature is "lossless editing and reexporting". Not to even mention that GarageBand is really really slow for tasks like this :/. However, this is a wonderful solution for a task that fulfills the subject, so I've +1'ed you for that aspect. Commented May 2, 2011 at 7:36
4

Quicktime 7 will do the work really easily.

Just open the video, and go to File > Export > Sound to AIFF/AU/Wave > select your path and you're done! :)

4
  • Looks like I may need to find my Snow Leopard disc... Commented May 2, 2011 at 17:12
  • @vxjasonxv you don't have to. You may downloaded via the provided link..
    – nuc
    Commented May 2, 2011 at 17:20
  • Oh, thanks! I didn't really think the link would actually be substantive in that manner. Commented May 2, 2011 at 21:38
  • 1
    Does the same pitfall I added to Rob's answer apply here? I can "save a wave" of the audio, but it's already compressed, and in theory in order to use it I'd have to recompress it again, which I'd rather not do. Commented May 14, 2011 at 4:16
4

QuickTime Player 10 is able to export audio (without re-encoding), too.

Select File > Export > Audio Only…

Tested on macOS 10.12 Sierra with QuickTime Player 10.4.

3
  • 1
    But does that re-encode the audio? Commented Dec 11, 2016 at 9:33
  • 1
    @JasonSalaz No, just extract. This is IMHO a better option. It is pretty quick and preserves quality. Moreover, you can re-encode it any time later.
    – Melebius
    Commented Dec 11, 2016 at 21:15
  • 1
    Awesome. My ffmpeg answer is also extract only so it probably only takes as much time as QuickTime. The benefit of ffmpeg is it doesn't have the inherent UI load weight, so it is undoubtedly faster at 1 file, and exponentially faster at many files. But this is a great answer for someone versed in Automator / Applescripting, and perhaps not as comfortable at the command line or with shell scripting. Commented Dec 11, 2016 at 21:35
2

The avconvert command powers the Services > Encode Selected Video Files option.

You can use it like so:

avconvert --quiet --preset PresetAppleM4A --source foo.mp4 --output bar.m4a
2
  • This is a fantastic command, it might replace my Handbrake workflow (… maybe), but it is a re-encode which this question was looking to avoid. The accepted answer, using FFMPEG to manipulate layers, is exactly what I need for this question in particular and have continued to use in this case for as many years as it has been. I appreciate being made aware of it. Commented Jul 15, 2020 at 20:37
  • 1
    ffmpeg is much better. This is a good alternative when you don't have it around. Commented Jul 16, 2020 at 0:44
2

This is an excellent option. You can use the built-in tool from apple to export only the audio channel.

avconvert --preset PresetPassthrough --source source.mp4 --output export.m4a
1
  • As long as the native tools can decode it. Commented Jul 21, 2023 at 7:42
1

I simply open the video file with audacity and then export the audio. I can set the exported audio file parameters during the export.

1
  • Setting audio file parameters means re-encoding the audio. Does Audacity have a pass through (unchanged extraction) option? Commented Dec 11, 2016 at 21:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .