OS X: Route audio output to audio input I'm watching a video file, and I'd like to record small snippets of audio from the video file.

Previously I have played the audio on my MacBook speakers and used the built-in microphone to record the sound.

Is there a way to route the Mac's audio output to the audio input (microphone) digitally, so I don't have to actually record the audio from the speakers, with the loss of quality this incurs?

Is there also a way to listen to the audio at the same time it's "recording"?

Ideally, the solution would be easy and light-weight and not involve heavy use of audio software, because I want to be able to do it "on the fly" as much as possible.
Update 2017-03-31:
Rogue Amoeba, the previous maintainers of the open source Soundflower project, has a new (paid) application called Loopback which seems to be easier and more dependable to work with than Soundflower. It solves some issues with Soundflower, like reenabling volume up/down via the Mac media keys. Again, it is a paid product with a trial mode. https://rogueamoeba.com/loopback/
Soundflower can still be found here: https://github.com/mattingalls/Soundflower

Soundflower is a virtual audio device for OS X that can pass audio from applications to other applications. It does this by routing your audio output as an audio input to the system.
Step 1
After installation, a new device will be available in System Preferences &gt; Sound. Go to the Input tab and select Soundflower (2ch) as the input device.

Step 2
If you want to route the audio and hear it yourself at the same time, skip to Step 3.
If you're okay with not having to hear the output yourself, you can now go to the Output tab and select Soundflower (2ch). You are now routing your Output to Input, and will be able to record the audio playing to an application like QuickTime, Evernote or Just Play Record.

Step 3
If you want to hear the audio while it's playing on your normal Output device (e.g. your Built-in speakers or attached headphones), you need to open the native OS X application Audio Midi Setup. It's located in your Applications folder under /Applications/Utilities.
Press the + button in the bottom left corner, and press Create Multi-Output Device. Mark to use both your Built-in Output and Soundflower (2ch). Now you can hear audio as usual while routing the Output into your Input via Soundflower.

Now that you have created a Multi-Output Device, go back to System Preferences &gt; Sound and select it on the Output tab as in Step 2.
Tip: You can also change the Input/Output settings by holding ⌥ (alt/opt) and left-clicking the Volume icon in the OS X menu bar.


Troubleshooting
HOWEVER, while the above will work at times, I have noticed that the behaviour of Soundflower can be erratic from time to time. When originally composing this answer, I couldn't get it to work even though I hadn't modified the setup that was working the day before.
It has stopped working a few times before, and while I haven't exactly identified how to mitigate the issue, I have noticed that something of the following may have helped to get it working again:

Check if the volume has been reset for the Multi-Output Device or any of it's sub-devices in Audio Midi Setup. Be sure to check all tabs (Input/Output) on both the aggregated Output device and and its aggregated sub-devices. There's quite a few tabs here, and the volume sliders on one of them may have been reset to zero. This has happened to me a few times.



Volume resetting to zero wouldn't have to be a big problem, if the normal volume controls (media keys and menu bar volume icon) worked as usual. But sometimes, the volume icon in the menu bar is grayed out and the volume can only be manipulated in Audio Midi Setup. I don't know why this sometimes happens, because when I use some other Multi-Output Devices I have created that also includes my other computer connected via Thunderbolt in Target Display Mode, I can magically use the volume media keys as normal. More experimentation is needed here.