How to identify codec (AAC vs ALAC) used in an m4a file

When I use the file command on an .m4a file, I get back a generic response of "ISO Media, Apple iTunes ALAC/AAC-LC (.M4A) Audio" for both AAC and ALAC files. I can think of two other approaches off the top of my head that don't require either the heavy hand of iTunes or installing new software :

  1. Open the audio file in question with QuickTime Player. Select "Show Movie Inspector" from the 'Window' menu (or press ⌘-i) to see the file's size, data rate, and the codec used in its creation.

  2. Use the afinfo (audio file info) command in Terminal.app to get a more information than QuickTime Player provides. Here's some sample output:

    $ afinfo /Users/admin/Desktop/01\ The\ Guns\ of\ August\ 1.m4a
    
    Num Tracks: 1 Data format: 2 ch,  44100 Hz, 'alac' (0x00000001) from
    16-bit source
    
    4096 frames/packet
    
    Channel layout: Stereo (L R)
    
    estimated duration: 18702.930431 sec audio bytes: 1006059541
    
    audio packets: 201367 bit rate: 430332 bits per second
    
    packet size upper bound: 12334 maximum packet size: 12334
    
    audio data file offset: 48
    
    optimized audio
    
    824799232 valid frames + 0 priming + 0 remainder = 824799232
    

For any readers unfamiliar with using the terminal, it's quite simple, and you won't break anything. Open Terminal, and type in--or cut and paste from below--the word afinfo followed by a single space:

afinfo 

Next, drag an audio file over to the Terminal window and drop it in. You will see the file's path get appended to the afinfo command. If dragging the icon caused the Finder to become the active process, you'll need to click on the Terminal's window to wake it up before the final step of pressing enter to run the command. If you like, you can get information on more than one file at a time by dragging and dropping multiple icons instead of just one. When you're finished, just quit Terminal.app as you would any other program.