How to identify codec (AAC vs ALAC) used in an m4a file
-
10-10-2020 - |
Frage
Given that the m4a format is merely a container, and can contain music encoded with a lossy (AAC) or lossless (ALAC) codec, is there a simple way to determine which codec was used for a given file?
Lösung
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 :
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.
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.
Andere Tipps
I wanted to do this in order to identify which m4a files in a folder were ALAC and which were AAC. This is easily done to an entire folder like this:
afinfo ./*.m4a |grep -B 4 alac
which gives a result like:
File: Track 09.m4a
File type ID: m4af
Num Tracks: 1
----
Data format: 2 ch, 44100 Hz, 'alac' (0x00000001) from 16-bit source, 4096 frames/packet
To just get the filenames, I used this:
afinfo ./*.m4a |grep -B 4 alac |grep File: |sed 's/.*\///'
resulting in:
Track 09.m4a
If you go to iTunes > View > View Options > Show Columns > Kind
it will include a column that tells you if the file is Apple Lossless or AAC