有許多音頻文件具有.m4a
後綴,並且這些音頻文件編碼在AAC或Apple Lossless(ALAC)之一中。我只想選擇Apple Lossless中編碼的音頻文件。有什麼方法可以確定嗎?我試過FFmpeg,但它說所有這些都是在AAC中編碼的。確定是否在Apple Lossless(ALAC)中編碼音頻文件
編輯:我目前在Windows上。
有許多音頻文件具有.m4a
後綴,並且這些音頻文件編碼在AAC或Apple Lossless(ALAC)之一中。我只想選擇Apple Lossless中編碼的音頻文件。有什麼方法可以確定嗎?我試過FFmpeg,但它說所有這些都是在AAC中編碼的。確定是否在Apple Lossless(ALAC)中編碼音頻文件
編輯:我目前在Windows上。
這裏是具有M4A的描述文件(最好我能找到到目前爲止)第67頁: http://iweb.dl.sourceforge.net/project/audiotools/audio%20formats%20reference/2.14/audioformats_2.14_letter.pdf
A typical M4A begins with an 'ftyp' atom indicating its file type... 10.2.1 the ftyp atom [0 31] ftyp Length [32 63] 'ftyp' (0x66747970) [64 95] Major Brand [96 127] Major Brand Version [128 159] Compatible Brand₁ ... The 'Major Brand' and 'Compatible Brand' elds are ASCII strings. 'Major Brand Version' is an integer.
在首先我認爲'ftyp'是格式確定的地方,但是通過這個列表判斷更像是文件類型本身(已知爲m4a): http://www.ftyps.com/index.html
http://www.ftyps.com/what.html描述了更多的格式。
如果FTYP不區分的話,我覺得「大品牌」字段可能是指FOURCC的這個網頁上: http://wiki.multimedia.cx/index.php?title=QuickTime_container 的一個蘋果無損是「ALAC」和AAC可能是「MP4A」
蘋果的無損格式的開源頁面指示FTYPE是「ALAC」(略矛盾以上) http://alac.macosforge.org/trac/browser/trunk/ALACMagicCookieDescription.txt
到目前爲止,我可以告訴的是,以下FTYP的4個字節總是(在一個很小的樣本量)'M4A'。
在第一個~200(十六進制)字節左右的某處,有一個用於AAC壓縮的ascii'mp4a'或用於Apple Lossless的'alac'。 'alac'似乎總是成對出現〜30個字節('mp4a'只有一次)。
對不起,這不是更具體,如果我找到確切的位置或前綴我會再次更新。 (我的猜測是頭部的前面部分有指定的大小。)
你可以用Core Audio來做到這一點。
喜歡的東西:
CFStringRef pathToFile;
CFURLRef inputFileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, pathToFile, kCFURLPOSIXPathStyle, false);
ExtAudioFileRef inputFile;
ExtAudioFileOpenURL(inputFileURL, &inputFile);
AudioStreamBasicDescription fileDescription;
UInt32 propertySize = sizeof(fileDescription);
ExtAudioFileGetProperty(inputFile,
kExtAudioFileProperty_FileDataFormat,
&propertySize,
&fileDescription);
if(fileDescription.mFormatID == kAudioFormatAppleLossless){
// file is apple lossless
}
哦謝謝你的回答,但我在Windows上。 – minhee
在Mac上,選擇所需的文件,然後右鍵單擊。找到「獲取信息」並單擊它,將彈出一個窗口,其中包含有關所選文件的額外信息。它應該在旁邊的「編解碼器:」「AAC」或「蘋果無損」 我希望我幫助那些有相同問題的Mac用戶(儘管我對操作系統不熟悉,但也可能有某些Windows用戶)。 )
使用try http://sourceforge.net/projects/mediainfo/
「的MediaInfo是視頻和音頻文件最相關的技術信息和標籤數據的方便統一的顯示。」 - sourceforge項目描述
這是如何顯示信息。
General
Complete name : C:\Downloads\recit24bit.m4a
Format : MPEG-4
Format profile : Apple audio with iTunes info
Codec ID : M4A
File size : 2.62 MiB
Duration : 9s 9ms
Overall bit rate : 2 441 Kbps
Track name : 24 bit recital ALAC Test File
Performer : N\A
Comment : Test File
Audio
ID : 1
Format : ALAC
Codec ID : alac
Codec ID/Info : Apple Lossless Format
Duration : 9s 9ms
Bit rate mode : Variable
Bit rate : 2 438 Kbps
Channel(s) : 2 channels
Sampling rate : 22.7 KHz
Bit depth : 24 bits
Stream size : 2.62 MiB (100%)
Language : English
查看編碼/編碼細節的音頻部分。
如果你有FFmpeg package,你應該有ffprobe
。
這給一試:
ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 file.m4a
-v error
:隱藏啓動文本-select_streams a:0
:選擇第一個音軌-show_entries stream=codec_name
:只顯示編解碼器類型-of default=noprint_wrappers=1:nokey=1
:刪除多餘的格式這將只打印出aac
或alac
。完美的腳本。
你在用什麼語言? – aglassman
你在做這是一種特定的語言還是你正在尋找一個基於CLI的Linux工具? – Lee
您是否嘗試過不同的FFMPEG版本?我很驚訝它沒有認識到正確的編解碼器。 – Brad