
OS Xのコマンドラインからafinfoを使用してMP3およびM4Aファイル情報を取得する
Mac OS XからMP3およびm4aファイルの情報を取得する最も速い方法は、ターミナルとafinfoコマンドを使用することです。使用するコマンドラインツールは、Audio File Info(オーディオファイル情報)の略で、まさにその名の通りです。任意のオーディオファイルで試してみることができますが、ここではmp3またはm4aファイルを対象としています。
開始するには、ターミナルを起動し、コマンド ラインで次のように入力して、オーディオ ファイルへのパスを指定し、メタ情報とファイルの詳細を取得します。
afinfo PATH/To/File.xxx
たとえば、iTunes フォルダに「filename.mp3」というドキュメントがあるとします。
afinfo ~/Music/iTunes/filename.mp3
すると、次のような一連の情報が報告されます。
File: ~/Music/iTunes/iTunes Music/Empire of the Sun/Empire of the Sun - Girl.mp3
File type ID: MPG3
Data format: 2 ch, 144100 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/packet, 0 bytes/frame
no channel layout.
estimated duration: 238.629 sec
audio bytes: 9545142
audio packets: 9135
bit rate: 320000 bits per second
packet size upper bound: 1052
maximum packet size: 1045
audio data file offset: 10302
optimized
このコマンドはMP3に限らず、あらゆるオーディオファイルで使用できます。以前、オーディオファイルのビットレートを確認する際にafinfoについて説明しました。
「afinfo」と入力するだけで、コマンドのオプションの便利なリストが表示されます。afinfo ツールではさまざまなことができるため、特にオーディオ愛好家にとっては楽しいものとなるはずです。
$ afinfo
Usage:
afinfo [option...] audio_file(s)
Options: (may appear before or after arguments)
{-h --help}
print help
{-b --brief}
print a brief (one line) description of the audio file
{-r --real}
get the estimated duration after obtaining the real packet count
{ --leaks }
run leaks at the end of the conversion
{ -i --info }
print contents of the InfoDictionary
{ -x --xml }
print output in xml format
{ --warnings }
print warnings if any (by default warnings are not printed in non-xml output mode)
これは、オーディオ形式に関するファイルデータを取得する以外にも、さまざまな用途に使用できます。ぜひ楽しんで、何に使用したかをお知らせください。