MP3文件格式解析


MP3文件格式解析
Peter Lee 2008-06-05
目錄
一、概述
二、整個MP3文件結構
三、MP3幀格式
1. 幀頭格式
2. MAIN_DATA
四、ID3標准
1. ID3V1
2. ID3V2
五、MP3文件實例剖析
六、資料
 
MP3 文件是由幀(frame)構成的,幀是 MP3 文件最小的組成單位。MP3 的全稱應為 MPEG1 Layer-3 音頻
文件,MPEG(Moving Picture Experts Group)在漢語中譯為活動圖像專家組,特指活動影音壓縮標准,MPEG
音頻文件是 MPEG1 標准中的聲音部分,也叫 MPEG 音頻層,它根據壓縮質量和編碼復雜程度划分為三層,即
Layer-1、Layer2、Layer3,且分別對應 MP1、MP2、MP3 這三種聲音文件,並根據不同的用途,使用不同層
次的編碼。MPEG 音頻編碼的層次越高,編碼器越復雜,壓縮率也越高,MP1 和 MP2 的壓縮率分別為 4:1 和
6:1-8:1,而 MP3 的壓縮率則高達 10:1-12:1,也就是說,一分鍾 CD 音質的音樂,未經壓縮需要 10MB
的存儲空間,而經過 MP3 壓縮編碼后只有 1MB 左右。不過 MP3 對音頻信號采用的是有損壓縮方式,為了降
低聲音失真度,MP3 采取了“感官編碼技術”,即編碼時先對音頻文件進行頻譜分析,然后用過濾器濾掉
噪音電平,接着通過量化的方式將剩下的每一位打散排列,最后形成具有較高壓縮比的 MP3 文件,並使壓
縮后的文件在回放時能夠達到比較接近原音源的聲音效果。
 
二、整個MP3 文件結構
MP3文件大體分為三部分:TAG_V2(ID3V2),Frame, TAG_V1(ID3V1)
ID3V2
包含了作者,作曲,專輯等信息,長度不固定,擴展了ID3V1的信息量。
Frame
.
.
.
Frame
一系列的幀,個數由文件大小和幀長決定
每個FRAME的長度可能不固定,也可能固定,由位率bitrate決定
每個FRAME又分為幀頭和數據實體兩部分
幀頭記錄了mp3的位率,采樣率,版本等信息,每個幀之間相互獨立
ID3V1
包含了作者,作曲,專輯等信息,長度為128BYTE。
 
三、MP3 幀格式
1.  幀頭格式
幀頭長4字節,對於固定位率的MP3文件,所有幀的幀頭格式一樣其數據結構如下:
 
typedef FrameHeader {
unsigned int sync: 11;                         // 同步信息
unsigned int version: 2;                       // 版本
unsigned int layer: 2;                                     //
unsigned int error protection: 1;                  // CRC 校驗
unsigned int bitrate_index: 4;             // 位率
unsigned int sampling_frequency: 2;         // 采樣頻率
unsigned int padding: 1;                     // 幀長調節
unsigned int private: 1;                        // 保留字
unsigned int mode: 2;                          // 聲道模式
unsigned int mode extension: 2;        // 擴充模式
unsigned int copyright: 1;                            //  版權
unsigned int original: 1;                       // 原版標志
unsigned int emphasis: 2;                   // 強調模式
}HEADER, *LPHEADER;
 
幀頭4字節使用說明見表1。
 
MP3幀長取決於位率和頻率,計算公式為:
 
. mpeg1.0       layer1 :   幀長= (48000*bitrate)/sampling_freq + padding
               layer2&3: 幀長= (144000*bitrate)/sampling_freq + padding
. mpeg2.0       layer1 :   幀長= (24000*bitrate)/sampling_freq + padding
layer2&3 : 幀長= (72000*bitrate)/sampling_freq + padding
例如:位率為64kbps,采樣頻率為44.1kHz,padding(幀長調節)為1時,幀長為210字節。
幀頭后面是可變長度的附加信息,對於標准的MP3文件來說,其長度是32字節,緊接其后的是壓縮的聲音數據,當解碼器讀到此處時就進行解碼了。
 
1 MP3 幀頭字節使用說明
名稱
位長
          
同步信息 11 12字節 所有位均為1,第1字節恆為FF
版本 2 00-MPEG 2.5   01-未定義     10-MPEG 2     11-MPEG 1
2 00-未定義      01-Layer 3     10-Layer 2      11-Layer 1
CRC校驗 1 0-校驗        1-不校驗
位率 4 3字節
  取樣率,單位是 kbps ,例如采用 MPEG-1 Layer 3 64kbps 是,值為 0101
bits V1,L1 V1,L2 V1,L3 V2,L1 V2,L2 V2,L3
0000 free free free free free free
0001 32 32 32 32(32) 32(8) 8 (8)
0010 64 48 40 64(48) 48(16) 16 (16)
0011 96 56 48 96(56) 56(24) 24 (24)
0100 128 64 56 128(64) 64(32) 32 (32)
0101 160 80 64 160(80) 80(40) 64 (40)
0110 192 96 80 192(96) 96(48) 80 (48)
0111 224 112 96 224(112) 112(56) 56 (56)
1000 256 128 112 256(128) 128(64) 64 (64)
1001 288 160 128 288(144) 160(80) 128 (80)
1010 320 192 160 320(160) 192(96) 160 (96)
1011 352 224 192 352(176) 224(112) 112 (112)
1100 384 256 224 384(192) 256(128) 128 (128)
1101 416 320 256 416(224) 320(144) 256 (144)
1110 448 384 320 448(256) 384(160) 320 (160)
1111 bad bad bad bad bad bad
V1 - MPEG 1    V2 - MPEG 2 and MPEG 2.5
L1 - Layer 1     L2 - Layer 2     L3 - Layer 3
"free" 
表示位率可變     "bad"   表示不允許值
采樣頻率 2
采樣頻率,對於 MPEG-1   00-44.1kHz    01-48kHz    10-32kHz      11- 未定義
           對於 MPEG-2   00-22.05kHz   01-24kHz    10-16kHz      11- 未定義
           對於 MPEG-2.5  00-11.025kHz 01-12kHz    10-8kHz       11- 未定義
幀長調節 1 用來調整文件頭長度,0-無需調整,1-調整,具體調整計算方法見下文。
保留字 1 沒有使用。
聲道模式 2 4字節 表示聲道, 00-立體聲Stereo    01-Joint Stereo    10-雙聲道        11-單聲道
擴充模式 2
當聲道模式為 01 是才使用。
Value 強度立體聲 MS立體聲
00 off off
01 on off
10 off on
11 on on
版權 1 文件是否合法,0-不合法   1-合法
原版標志 1 是否原版,    0-非原版   1-原版
強調方式 2
用於聲音經降噪壓縮后再補償的分類,很少用到,今后也可能不會用。
00- 未定義      01-50/15ms     10- 保留        11-CCITT J.17
 
MAIN_DATA 部分長度是否變化決定於 FRAMEHEADER 的 bitrate 是否變化,一首 MP3 歌曲,它有三個版
本:96Kbps(96 千比特位每秒)、128Kbps 和 192Kbps。Kbps(比特位速率),表明了音樂每秒的數據量,
Kbps 值越高,音質越好,文件也越大,MP3 標准規定,不變的 bitrate 的 MP3 文件稱作 CBR,大多數 MP3
文件都是 CBR 的,而變化的 bitrate 的 MP3 文件稱作 VBR,每個 FRAME 的長度都可能是變化的。下面是 CBR
和 VBR 的不同點:
1)CBR:固定位率的 FRAME 的大小是固定的(公式如上所述),只要知道文件總長度,和幀長即可由播放每幀需 26ms 計算得出 mp3 播放的總時間,也可通過計數幀的個數控制快進、快退慢放等操作。注:有些時候, 並不是所有的幀都是等長的,有的幀可能多一個或幾個字節。
2)VBR:VBR 是 XING 公司推出的算法,所以在 MP3 的 FRAME 里會有“XING"這個關鍵字(現在很多流行的
小軟件也可以進行 VBR 壓縮,它們是否遵守這個約定,那就不得而知了),它存放在 MP3 文件中的第一個有效 FRAME 里,它標識了這個 MP3 文件是 VBR 的。同時第一個 FRAME 里存放了 MP3 文件的 FRAME 的總個數,這就很容易獲得了播放總時間,同時還有 100 個字節存放了播放總時間的 100 個時間分段的 FRAME 的 INDEX,假設 4 分鍾的 MP3 歌曲,240S,分成 100 段,每兩個相鄰 INDEX 的時間差就是 2.4S,所以通過這個 INDEX,只要前后處理少數的 FRAME,就能快速找出我們需要快進的 FRAME 頭。
2 VBR 文件第一幀結構
    
14 CBR相同的標准聲音幀頭
540 存放VBR文件標識“Xing”(58 69 6E 67),此標識具體位置視采用的MPEG標准和聲道模式而定。標識的前后字節沒有使用。
3639 MPEG-1和非單聲道(常見)
2124 MPEG-1和單聲道
2124 MPEG-2和非單聲道
1316 MPEG-2和單聲道
4144 標志,說明是否存儲了幀數、文件長度、目錄表和VBR規模信息,如果存儲了,則01 02 04 08
4548 幀數(包括第一幀)
4952 文件長度
53152 目錄表,用來按時間進行字節定位。
153156 VBR規模,用於位率變動
 
另可參考下文:
This system was created to minimize file lengths and to preserve sound quality.
Higher frequencies generally needs more space for encoding (thats why many codecs cut all
frequencies above cca 16kHz) and lower tones requires less. So if some part of song doesnt consistof higher tones then using eg. 192kbps is wasting of space. It should be enough to use only eg.96kbps.
And it is the principle of VBR. Codec looks over frame and then choose bitrate suitable for itssound quality.
It sounds perfect but it brings some problems:
If you want to jump over 2 minutes in song, it is not a problem with CBR because you are able
simply count amount of Bytes which is necessary to skip. But it is impossible with VBR. Frame
lengths should be arbitrary so you have to either go frame by frame and counts (time consuming
and very unpractical) or use another mechanism for approximate count.
If you want to cut 5 minutes from the middle of VBR file (all we know CDs where last song takes
10 minutes but 5 minutes is a pure silence, HELL!) problems are the same.
Result? VBR files are more difficult for controlling and adjusting. And I dont like feeling that
sound quality changes in every moment. And AFAIK many codecs have problems with creation VBR ingood quality.
Personally I cant see any reason why to use VBR - I dont give a fuck if size of one CD in MP3is 55 MB with CBR or 51 MB with VBR. But everybody has a different taste... some people preferVBR.
VBR File Structureis the same as for CBR. But the first frame doesnt contain audio data and it is used for special
information about VBR file.
Structure of the first frame:
Byte         Content
0-3          Standard audio frame header (as descripted above). Mostly it contains values FF
             FB 30 4C, from which you can count FrameLen = 156 Bytes. And thats exactly enough
             space for storing VBR info.
             This header contains some important information valid for the whole file:
             - MPEG (MPEG1 or MPEG2)
             - SAMPLING rate frequency index
             - CHANNEL (JointStereo etc.)
4-x          Not used till string "Xing" (58 69 6E 67). This string is used as a main VBR file
             identifier. If it is not found, file is supposed to be CBR. This string can be placed
             at different locations according to values of MPEG and CHANNEL (ya, these from a
             few lines upwards):
36-39        "Xing" for MPEG1 and CHANNEL != mono (mostly used)
21-24        "Xing" for MPEG1 and CHANNEL == mono
21-24        "Xing" for MPEG2 and CHANNEL != mono
13-16        "Xing" for MPEG2 and CHANNEL == mono
             After "Xing" string there are placed flags, number of frames in file and a size
             of file in Bytes. Each of these items has 4 Bytes and it is stored as 'int' number
             in memory. The first is the most significant Byte and the last is the least.
             Following schema is for MPEG1 and CHANNEL != mono:
40-43        Flags
              Value         Name              Description
              00 00 00 01   Frames Flag       set if value for number of frames in file is stored
              00 00 00 02   Bytes Flag        set if value for filesize in Bytes is stored
              00 00 00 04   TOC Flag          set if values for TOC (see below) are stored
              00 00 00 08   VBR Scale Flag    set if values for VBR scale are stored
             All these values can be stored simultaneously.
44-47        Frames
             Number of frames in file (including the first info one)
48-51        Bytes
             File length in Bytes
52-151       TOC (Table of Contents)
              Contains of 100 indexes (one Byte length) for easier lookup in file. Approximately
              solves problem with moving inside file.
              Each Byte has a value according this formula:
              (TOC[i] / 256) * fileLenInBytes
              So if song lasts eg. 240 sec. and you want to jump to 60. sec. (and file is 5 000
              000 Bytes length) you can use:
              TOC[(60/240)*100] = TOC[25]
              and corresponding Byte in file is then approximately at:
              (TOC[25]/256) * 5000000
              If you want to trim VBR file you should also reconstruct Frames, Bytes and TOC
              properly.
152-155       VBR Scale
              I dont know exactly system of storing of this values but this item probably doesnt
              have deeper meaning.
 
四、ID3 標准
MP3 幀頭中除了存儲一些象 private copyright original 的簡單音樂說明信息以外,沒有考慮存放歌名、作者、專輯名、年份等復雜信息,而這些信息在 MP3 應用中非常必要。 1996 年, FricKemp 在“ Studio 3”項目中提出了在MP3 文件尾增加一塊用於存放歌曲的說明信息,形成了 ID3 標准,至今已制定出 ID3 V1.0 V1.1 V2.0 V2.3 V2.4 標准。版本越高,記錄的相關信息就越豐富詳盡。
ID3 V1.0 標准並不周全,存放的信息少,無法存放歌詞,無法錄入專輯封面、圖片等。 V2.0 是一個相當完備的標准,但給編寫軟件帶來困難,雖然贊成此格式的人很多,在軟件中真正實現的卻極少。絕大多數 MP3 仍使用 ID3 V1.0 標准。此標准是將 MP3 文件尾的最后 128 個字節用來存放 ID3 信息,這 128 個字節使用說明見表 3
3 ID3 V1.0 文件尾說明
字節 長度 (字節)        
1-3 3 存放“TAG”字符,表示ID3 V1.0標准,緊接其后的是歌曲信息。
4-33 30 歌名
34-63 30 作者
64-93 30 專輯名
94-97 4 年份
98-127 30 附注
128 1 MP3音樂類別,共147種。
4 MP3 音樂類別:
0 'Blues' 20 'Alternative' 40 'AlternRock' 60 'Top 40'
1 'Classic Rock' 21 'Ska' 41 'Bass' 61 'Christian Rap'
2 'Country' 22 'Death Metal' 42 'Soul' 62 'Pop/Funk'
3 'Dance' 23 'Pranks' 43 'Punk' 63 'Jungle'
4 'Disco' 24 'Soundtrack' 44 'Space' 64 'Native American'
5 'Funk' 25 'Euro-Techno' 45 'Meditative' 65 'Cabaret'
6 'Grunge' 26 'Ambient' 46 'Instrumental Pop' 66 'New Wave'
7 'Hip-Hop' 27 'Trip-Hop' 47 'Instrumental Rock' 67 'Psychadelic'
8 'Jazz' 28 'Vocal' 48 'Ethnic' 68 'Rave'
9 'Metal' 29 'Jazz+Funk' 49 'Gothic' 69 'Showtunes'
10 'New Age' 30 'Fusion' 50 'Darkwave' 70 'Trailer'
11 'Oldies' 31 'Trance' 51 'Techno-Industrial' 71 'Lo-Fi'
12 'Other' 32 'Classical' 52 'Electronic' 72 'Tribal'
13 'Pop' 33 'Instrumental' 53 'Pop-Folk' 73 'Acid Punk'
14 'R&B' 34 'Acid' 54 'Eurodance' 74 'Acid Jazz'
15 'Rap' 35 'House' 55 'Dream' 75 'Polka'
16 'Reggae' 36 'Game' 56 'Southern Rock' 76 'Retro'
17 'Rock' 37 'Sound Clip' 57 'Comedy' 77 'Musical'
18 'Techno' 38 'Gospel' 58 'Cult' 78 'Rock & Roll'
19 'Industrial' 39 'Noise' 59 'Gangsta' 79 'Hard Rock'
               
80 Folk 81 Folk/Rock 82 National Folk 83 Swing
84 Fast-Fusion 85 Bebob 86 Latin 87 Revival
88 Celtic 89 Bluegrass 90 Advantgarde 91 Gothic Rock
92 Progressive Rock 93 Psychadelic Rock 94 Symphonic Rock 95 Slow Rock
96 Big Band 97 Chorus 98 Easy Listening 99 Acoustic
100 Humour 101 Speech 102 Chanson 103 Opera
104 Chamber Music 105 Sonata 106 Symphony 107 Booty Bass
108 Primus 109 Porn Groove 110 Satire 111 Slow Jam
112 Club 113 Tango 114 Samba 115 Folklore
Any other value should be considered as 'Unknown'
 
ID3V2 到現在一共有 4 個版本,但流行的播放軟件一般只支持第 3 版,既 ID3v2.3。由於 ID3V1 記錄
在 MP3 文件的末尾,ID3V2 就只好記錄在 MP3 文件的首部了(如果有一天發布 ID3V3,真不知道該記錄在哪
里)。也正是由於這個原因,對 ID3V2 的操作比 ID3V1 要慢。而且 ID3V2 結構比 ID3V1 的結構要復雜得多,
但比前者全面且可以伸縮和擴展。
 下面就介紹一下 ID3V2.3。
 每個 ID3V2.3 的標簽都一個標簽頭和若干個標簽幀或一個擴展標簽頭組成。關於曲目的信息如標題、作者
等都存放在不同的標簽幀中,擴展標簽頭和標簽幀並不是必要的,但每個標簽至少要有一個標簽幀。標簽
頭和標簽幀一起順序存放在 MP3 文件的首部。
1、標簽頭
在文件的首部順序記錄 10 個字節的 ID3V2.3 的頭部。數據結構如下:
 char Header[3];     /*必須為"ID3"否則認為標簽不存在*/
 char Ver;     /*版本號 ID3V2.3 就記錄 3*/
 char Revision;     /*副版本號此版本記錄為 0*/
 char Flag;     /*存放標志的字節,這個版本只定義了三位,稍后詳細解說*/
 char Size[4];     /*標簽大小,包括標簽頭的 10 個字節和所有的標簽幀的大小*/
 1).標志字節
 標志字節一般為 0,定義如下:
 abc00000
 a -- 表示是否使用 Unsynchronisation(這個單詞不知道是什么意思,字典里也沒有找到,一般不設置)
 b -- 表示是否有擴展頭部,一般沒有(至少 Winamp 沒有記錄),所以一般也不設置
 c -- 表示是否為測試標簽(99.99%的標簽都不是測試用的啦,所以一般也不設置)
 2).標簽大小
 一共四個字節,但每個字節只用 7 位,最高位不使用恆為 0。所以格式如下
 0xxxxxxx 0xxxxxxx 0xxxxxxx 0xxxxxxx
 計算大小時要將 0 去掉,得到一個 28 位的二進制數,就是標簽大小(不懂為什么要這樣做),計算公式如
下:
 int total_size;
 total_size =    (Size[0]&0x7F)*0x200000
   +(Size[1]&0x7F)*0x400
   +(Size[2]&0x7F)*0x80
   +(Size[3]&0x7F)
2、標簽幀
每個標簽幀都有一個 10 個字節的幀頭和至少一個字節的不固定長度的內容組成。                    它們也是順序存放在文件
中,和標簽頭和其他的標簽幀也沒有特殊的字符分隔。得到一個完整的幀的內容只有從幀頭中的到內容大
小后才能讀出,讀取時要注意大小,不要將其他幀的內容或幀頭讀入。
幀頭的定義如下:
 char FrameID[4];   /*用四個字符標識一個幀,說明其內容,稍后有常用的標識對照表*/
 char Size[4];    /*幀內容的大小,不包括幀頭,不得小於 1*/
 char Flags[2];    /*存放標志,只定義了 6 位,稍后詳細解說*/
 1).幀標識
 用四個字符標識一個幀,說明一個幀的內容含義,常用的對照如下:
 TIT2=標題 表示內容為這首歌的標題,下同
 TPE1=作者
 TALB=專集
 TRCK=音軌 格式:N/M        其中 N 為專集中的第 N 首,M 為專集中共 M 首,N 和 M 為 ASCII 碼表示的數字
 TYER=年代 是用 ASCII 碼表示的數字
 TCON=類型 直接用字符串表示
 COMM=備注 格式:"eng/0 備注內容",其中 eng 表示備注所使用的自然語言
 2).大小
 這個可沒有標簽頭的算法那么麻煩,每個字節的 8 位全用,格式如下
 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
 算法如下:
 int FSize;
 FSize = Size[0]*0x100000000
 +Size[1]*0x10000
 +Size[2]*0x100
 +Size[3];
 3).標志
 只定義了 6 位,另外的 10 位為 0,但大部分的情況下 16 位都為 0 就可以了。格式如下:
 abc00000 ijk00000
 a -- 標簽保護標志,設置時認為此幀作廢
 b -- 文件保護標志,設置時認為此幀作廢
 c -- 只讀標志,設置時認為此幀不能修改(但我沒有找到一個軟件理會這個標志)
 i -- 壓縮標志,設置時一個字節存放兩個 BCD 碼表示數字
 j -- 加密標志(沒有見過哪個 MP3 文件的標簽用了加密)
 k -- 組標志,設置時說明此幀和其他的某幀是一組
 值得一提的是 winamp 在保存和讀取幀內容的時候會在內容前面加個'/0',並把這個字節計算在幀內容的
大小中。
: 幀標識的含義
4).    Declared ID3v2 frames
   The following frames are declared in this draft.
 AENC Audio encryption
 APIC Attached picture
 COMM Comments
 COMR Commercial frame
 ENCR Encryption method registration
 EQUA Equalization
 ETCO Event timing codes
 GEOB General encapsulated object
 GRID Group identification registration
 IPLS Involved people list
 LINK Linked information
 MCDI Music CD identifier
 MLLT MPEG location lookup table
 OWNE Ownership frame
 PRIV Private frame
 PCNT Play counter
 POPM Popularimeter
 POSS Position synchronisation frame
 RBUF Recommended buffer size
 RVAD Relative volume adjustment
 RVRB Reverb
 SYLT Synchronized lyric/text
 SYTC Synchronized tempo codes
 TALB Album/Movie/Show title
 TBPM BPM (beats per minute)
 TCOM Composer
 TCON Content type
 TCOP Copyright message
 TDAT Date
 TDLY Playlist delay
 TENC Encoded by
 TEXT Lyricist/Text writer
 TFLT File type
TIME Time
TIT1 Content group description
TIT2 Title/songname/content description
TIT3 Subtitle/Description refinement
TKEY Initial key
TLAN Language(s)
TLEN Length
TMED Media type
TOAL Original album/movie/show title
TOFN Original filename
TOLY Original lyricist(s)/text writer(s)
TOPE Original artist(s)/performer(s)
TORY Original release year
TOWN File owner/licensee
TPE1 Lead performer(s)/Soloist(s)
TPE2 Band/orchestra/accompaniment
TPE3 Conductor/performer refinement
TPE4 Interpreted, remixed, or otherwise modified by
TPOS Part of a set
TPUB Publisher
TRCK Track number/Position in set
TRDA Recording dates
TRSN Internet radio station name
TRSO Internet radio station owner
TSIZ Size
TSRC ISRC (international standard recording code)
TSSE Software/Hardware and settings used for encoding
TYER Year
TXXX User defined text information frame
UFID Unique file identifier
USER Terms of use
USLT Unsychronized lyric/text transcription
WCOM Commercial information
WCOP Copyright/Legal information
WOAF Official audio file webpage
WOAR Official artist/performer webpage
WOAS Official audio source webpage
WORS Official internet radio station homepage
WPAY Payment
WPUB Publishers official webpage
WXXX User defined URL link frame
 
五、MP3 文件實例剖析
VC++ 中打開一個名為 test.mp3 文件,其內容如下:
000000  FF FB 52 8C 00 00 01 49 09 C5 05 24 60 00 2A C1
000010  19 40 A6 00 00 05 96 41 34 18 20 80 08 26 48 29
000020  83 04 00 01 61 41 40 50 10 04 00 C1 21 41 50 64
……
0000D0  FE FF FB 52 8C 11 80 01 EE 90 65 6E 08 20 02 30
0000E0  32 0C CD C0 04 00 46 16 41 89 B8 01 00 08 36 48
0000F0 33 B7 00 00 01 02 FF FF FF F4 E1 2F FF FF FF FF
……
0001A0  DF FF FF FB 52 8C 12 00 01 FE 90 58 6E 09 A0 02
0001B0  33 B0 CA 85 E1 50 01 45 F6 19 61 BC 26 80 28 7C
0001C0  05 AC B4 20 28 94 FF FF FF FF FF FF FF FF FF FF
……
001390  7F  FF FF FF FD 4E 00 54 41 47 54 45 53 54 00 00
0013A0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
……
0013F0 00 00 00 00 04 19 14 03 00 00 00 00 00 00 00 00
001400  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
001410  00 00 00 00 00 00 4E
該文件長度 1416H 5.142K ),幀頭為: FF FB 52 8C ,轉換成二進制為:
11111111 11111011
01010010 10001100
對照表 1 可知, test.mp3 幀頭信息見表 5
5 test.mp3 文件幀頭信息
名稱 位值      
同步信息 11111111111 1字節恆為FF11位均為1
版本 11 MPEG 1
01 Layer 3
CRC校驗 1 不校驗
位率 0101 64kbps
頻率 00 44.1kHz
幀長調節 1 調整,幀長是210字節。
保留字 0 沒有使用。
聲道模式 10 雙聲道
擴充模式 00 未使用。
版權 1 合法
原版標志 1 原版
強調方式 00 未定義
1397H 開始的三個字節是 54 41 47 ,存放的是字符“ TAG ”,表示此文件有 ID3 V1.0 信息。
139AH 開始的 30 個字節存放歌名,前 4 個非 00 字節是 54 45 53 54 ,表示“ TEST ”;
13F 4H 開始的 4 個字節是 04 19 14 03 ,存放年份“ 04/25/2003 ”;
最后 1 個字節是 4E ,表示音樂類別,代號為 78 ,即“ Rock&Roll ”;
其它字節均為 00 ,未存儲信息。
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM