⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpeghdr.htm

📁 关于音频转换的一些资料
💻 HTM
字号:
<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta name="AUTHOR" content="Predrag Supurovic, broker@dv.co.yu"><meta name="KEYWORDS" content="mpeg, mp3, header, coding, programming,structure, frame, = audio, music, file, format"><meta name="GENERATOR" content="handmade"><title>MPEG AUDIO FRAME HEADER</title></head><body bgcolor="#FFFFFF"><p>This is a brief and informal document targeted to those who want to dealwith the MPEG format. If you are one of them, you probably already know whatis MPEG audio. If not, jump to <ahref="http://www.mp3.com/">http://www.mp3.com/</a> or <ahref="http://www.layer3.org/">http://www.layer3.org/</a> where you will findmore details and also more links.</p><p>NOTE: You cannot just search the Internet and find the MPEG audio specs. Itis copyrighted and you will have to pay quite a bit to get the Paper. That'swhy I made this. Informations I got are gathered from the internet, and mostlyoriginate from sources I found available. Despite my custom to always specifythe sources, I am not able to do it this time. Sorry, I did not maintain thelist. :(</p><p><b>This is not decoding specs, it just informs you how to read the </b><ahref="#MPEG HEADER"><b>MPEG headers</b></a><b> and the </b> <a href="#MPEGTAG"><b>MPEG TAG</b></a><b>. MPEG Version 1, 2 and 2.5 and Layer I, II and IIIare supported, the MP3 TAG (MP3v1 and MP3v1.1) also.</b>.  Those of you who use Delphi may find my <a href="http://www.dv.co.yu/mp3list/mpgtools.htm">MPGTools Delphi unit</a> useful, it is where I implemented this stuff.<p align="center"><a name="MPEG HEADER"><font size="5"><b>MPEG Audio FrameHeader</b></font><p>An MPEG audio file is separated in smaller parts called frames. Each frameis independent. It has its own header and audio informations. There is no fileheader. Therefore, you can cut any part of MPEG file and play it correctly.<p>When you want to read info about an MPEG file, it is usually enough to findthe first frame, read its header and assume that the other frames are the same(which may not be always the case).<p>The frame header is constituated by the very first four bytes (32bits) in aframe. The first eleven bits of a frame header are always set and they arecalled &quot;frame sync&quot;. Therefore, you can search through the file forthe first occurence of eleven bits set (meaning that you have to find a bytewith a value of 255, and followed by a byte with its three most significantbits set). Then you read the whole header and check if the values are correct.You will see in next table the exact meaning of each bits in the header, andwhich values may be checked for validity. Each value that is specified asreserved, invalid, bad, or not allowed should indicate an invalid header.<p>Frames may have a CRC check, but it's pretty rare. The CRC is 16 bits longand, if it exists, it follows the frame header. After the CRC comes the audiodata. You may calculate the length of the frame and use it if you need to readother headers too or just want to calculate the CRC of the frame, to compareit with the one you read from the file. This is actually a very good method tocheck the MPEG header validity.<p>Here is &quot;graphical&quot; presentation of the header content. Theletters are used to indicate the different fields. In the table, you can seethe details about the content of each field.<p align="center"><b><tt><font size="5">AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM</FONT></tt></b><P><center><table border="0" width="500" CELLSPACING=7><tr VALIGN=TOP bgcolor="#E2E2E2"><td>Sign</td><td>Length<br>(bits)</td><td>Position<br>(bits)</td><td>Description</td></tr><tr VALIGN=TOP><td>A</td><td>11</td><td>(31-21)</td><td>Frame sync (all bits set)</td></tr><tr VALIGN=TOP><td>B</td><td>2</td><td>(20,19)</td><td>MPEG Audio version<br>00 - MPEG Version 2.5<br>01 - reserved<br>10 - MPEG Version 2<br>11 - MPEG Version 1</td></tr><tr VALIGN=TOP><td>C</td><td>2</td><td>(18,17)</td><td>Layer description<br>00 - reserved<br>01 - Layer III<br>10 - Layer II<br>11 - Layer I</td></tr><tr VALIGN=TOP><td>D</td><td>1</td><td>(16)</td><td>Protection bit<br>0 - Protected by CRC (16bit crc follows header)<br>1 - Not protected</td></tr><tr VALIGN=TOP><td>E</td><td>4</td><td>(15,12)</td><td>Bitrate index<br><table border="1" cellspacing="0" cellpading="0"><tr><td>bits</td><td>V1,L1</td><td>V1,L2</td><td>V1,L3</td><td>V2,L1</td><td>V2,L2</td><td>V2,L3</td></tr><tr><td>0000</td><td>free</td><td>free</td><td>free</td><td>free</td><td>free</td><td>free</td></tr><tr><td>0001</td><td>32</td><td>32</td><td>32</td><td>32</td><td>32</td><td>8 (8)</td></tr><tr><td>0010</td><td>64</td><td>48</td><td>40</td><td>64</td><td>48</td><td>16 (16)</td></tr><tr><td>0011</td><td>96</td><td>56</td><td>48</td><td>96</td><td>56</td><td>24 (24)</td></tr><tr><td>0100</td><td>128</td><td>64</td><td>56</td><td>128</td><td>64</td><td>32 (32)</td></tr><tr><td>0101</td><td>160</td><td>80</td><td>64</td><td>160</td><td>80</td><td>64 (40)</td></tr><tr><td>0110</td><td>192</td><td>96</td><td>80</td><td>192</td><td>96</td><td>80 (48)</td></tr><tr><td>0111</td><td>224</td><td>112</td><td>96</td><td>224</td><td>112</td><td>56 (56)</td></tr><tr><td>1000</td><td>256</td><td>128</td><td>112</td><td>256</td><td>128</td><td>64 (64)</td></tr><tr><td>1001</td><td>288</td><td>160</td><td>128</td><td>288</td><td>160</td><td>128 (80)</td></tr><tr><td>1010</td><td>320</td><td>192</td><td>160</td><td>320</td><td>192</td><td>160 (96)</td></tr><tr><td>1011</td><td>352</td><td>224</td><td>192</td><td>352</td><td>224</td><td>112 (112)</td></tr><tr><td>1100</td><td>384</td><td>256</td><td>224</td><td>384</td><td>256</td><td>128 (128)</td></tr><tr><td>1101</td><td>416</td><td>320</td><td>256</td><td>416</td><td>320</td><td>256 (144)</td></tr><tr><td>1110</td><td>448</td><td>384</td><td>320</td><td>448</td><td>384</td><td>320 (160)</td></tr><tr><td>1111</td><td>bad</td><td>bad</td><td>bad</td><td>bad</td><td>bad</td><td>bad</td></tr></table><p>NOTES: All values are in kbps<br>V1 - MPEG Version 1<br>V2 - MPEG Version 2 and Version 2.5<br>L1 - Layer I<br>L2 - Layer II<br>L3 - Layer III<br>&quot;free&quot; means variable bitrate.<br>&quot;bad&quot; means that this is not an allowed value<p>The values in parentheses are from different sources which claim that thosevalues are valid for V2,L2 and V2,L3. If anyone can confirm please let meknow.</td></tr><tr VALIGN=TOP><td>F</td><td>2</td><td>(11,10)</td><td>Sampling rate frequency index (values are in Hz)<table border="1" cellspacing="0" cellpading="0"><tr>  <td>bits</td><td>MPEG1</td><td>MPEG2</td><td>MPEG2.5</td></tr><tr> <td>00</td><td>44100</td><td>22050</td><td>11025</td></tr><tr> <td>01</td><td>48000</td><td>24000</td><td>12000</td></tr><tr><td>10</td><td>32000</td><td>16000</td><td>8000</td></tr><tr><td>11</td><td>reserv.</td><td>reserv.</td><td>reserv.</td></tr></table></td></tr><tr VALIGN=TOP><td>G</td><td>1</td><td>(9)</td><td>Padding bit<br>0 - frame is not padded<br>1 - frame is padded with one extra bit</td></tr><tr VALIGN=TOP><td>H</td><td>1</td><td>(8)</td><td>Private bit (unknown purpose)</td></tr><tr VALIGN=TOP><td>I</td><td>2</td><td>(7,6)</td><td>Channel Mode<br>00 - Stereo<br>01 - Joint stereo (Stereo)<br>10 - Dual channel (Stereo)<br>11 - Single channel (Mono)</td></tr><tr VALIGN=TOP><td>J</td><td>2</td><td>(5,4)</td><td>Mode extension (Only if Joint stereo)<br><table border="1" cellspacing="0" cellpading="0"><tr><td>value</td><td>Intensity stereo</td><td>MS stereo</td></tr><tr><td>00</td><td>off</td><td>off</td></tr><tr><td>01</td><td>on</td><td>off</td></tr><tr><td>10</td><td>off</td><td>on</td></tr><tr><td>11</td><td>on</td><td>on</td></tr></table></td></tr><tr VALIGN=TOP><td>K</td><td>1</td><td>(3)</td><td>Copyright<br>0 - Audio is not copyrighted<br>1 - Audio is copyrighted</td></tr><tr VALIGN=TOP><td>L</td><td>1</td><td>(2)</td><td>Original<br>0 - Copy of original media<br>1 - Original media</td></tr><tr VALIGN=TOP><td>M</td><td>2</td><td>(1,0)</td><td>Emphasis<br>00 - none<br>01 - 50/15 ms<br>10 - reserved<br>11 - CCIT J.17</td></tr></table></center><p><b>How to calculate frame size</b><p>Read the BitRate, SampleRate and Padding (as value of one or zero) of theframe header and use the formula:<p ALIGN=CENTER>FrameSize = 144 * BitRate / SampleRate + Padding<p>Example: BitRate = 128000, SampleRate=441000, Padding=0 &nbsp;==&gt;&nbsp;FrameSize=417 bytes<p align="center"><a name="MPEG TAG"><font size="5"><b>MPEG AudioTag MP3v1</b></font><p>The TAG is used to describe the MPEG Audio file. It contains informationabout artist, title, album, publishing year and genre. There is some extraspace for comments. It is exactly 128 bytes long and is located at very end ofthe audio data. You can get it by reading the last 128 bytes of the MPEG audiofile.<p align="center"><font size="5"><b><tt>AAABBBBB BBBBBBBB BBBBBBBB BBBBBBBB<br>BCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCD<br>DDDDDDDD DDDDDDDD DDDDDDDD DDDDDEEE<br>EFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFG<br></tt></b></font><center><table border="0" width="500"><tr VALIGN=TOP BGCOLOR=#E2E2E2> <td>Sign</td><td>Length<br>(bytes)</td><td>Position<br>(bytes)</td><td>Description</td></tr><tr VALIGN=TOP> <TD>A</td><TD>3</td><td>(0-2)</td><td>Tag identification.Must contain 'TAG' if tag exists and is correct.</td></tr><tr> <td>B</td><td>30</td><td>(3-32)</td><td>Title</td></tr><tr> <td>C</td><td>30</td><td>(33-62)</td><td>Artist</td></tr><tr> <td>D</td><td>30</td><td>(63-92)</td><td>Album</td></tr><tr> <td>E</td><td>4</td><td>(93-96)</td><td>Year</td></tr><tr> <td>F</td><td>30</td><td>(97-126)</td><td>Comment</td></tr><tr> <td>G</td><td>1</td><td>(127)</td><td>Genre</td></tr></table></center><p>The specification asks for all fields to be padded with null character(ASCII 0). However, not all applications respect this (an example is WinAmpwhich pads fields with &lt;space&gt;, ASCII 32).<p>There is a small change proposed in <B>MP3v1.1</B> structure. The last byte of the Comment field may be used to specify the track number of a song in an album. It should contain a null character (ASCII 0) if the information is unknown.<p>Genre is a numeric field which may have one of the following values:<CENTER><table border="0" width="90%"><tr><td width="1%">0</td><td width="20%">'Blues'</td><td width="1%">20</td><td width="20%">'Alternative'</td><td width="1%">40</td><td width="20%">'AlternRock'</td><td width="1%">60</td><td width="20%">'Top 40'</td></tr><tr><td>1</td><td>'Classic Rock'</td><td>21</td><td>'Ska'</td><td>41</td><td>'Bass'</td><td>61</td><td>'Christian Rap'</td></tr><tr><td>2</td><td>'Country'</td><td>22</td><td>'Death Metal'</td><td>42</td><td>'Soul'</td><td>62</td><td>'Pop/Funk'</td></tr><tr><td>3</td><td>'Dance'</td><td>23</td><td>'Pranks'</td><td>43</td><td>'Punk'</td><td>63</td><td>'Jungle'</td></tr><tr><td>4</td><td>'Disco'</td><td>24</td><td>'Soundtrack'</td><td>44</td><td>'Space'</td><td>64</td><td>'Native American'</td></tr><tr><td>5</td><td>'Funk'</td><td>25</td><td>'Euro-Techno'</td><td>45</td><td>'Meditative'</td><td>65</td><td>'Cabaret'</td></tr><tr><td>6</td><td>'Grunge'</td><td>26</td><td>'Ambient'</td><td>46</td><td>'Instrumental Pop'</td><td>66</td><td>'New Wave'</td></tr><tr><td>7</td><td>'Hip-Hop'</td><td>27</td><td>'Trip-Hop'</td><td>47</td><td>'Instrumental Rock'</td><td>67</td><td>'Psychadelic'</td></tr><tr><td>8</td><td>'Jazz'</td><td>28</td><td>'Vocal'</td><td>48</td><td>'Ethnic'</td><td>68</td><td>'Rave'</td></tr><tr><td>9</td><td>'Metal'</td><td>29</td><td>'Jazz+Funk'</td><td>49</td><td>'Gothic'</td><td>69</td><td>'Showtunes'</td></tr><tr><td>10</td><td>'New Age'</td><td>30</td><td>'Fusion'</td><td>50</td><td>'Darkwave'</td><td>70</td><td>'Trailer'</td></tr><tr><td>11</td><td>'Oldies'</td><td>31</td><td>'Trance'</td><td>51</td><td>'Techno-Industrial'</td><td>71</td><td>'Lo-Fi'</td></tr><tr><td>12</td><td>'Other'</td><td>32</td><td>'Classical'</td><td>52</td><td>'Electronic'</td><td>72</td><td>'Tribal'</td></tr><tr><td>13</td><td>'Pop'</td><td>33</td><td>'Instrumental'</td><td>53</td><td>'Pop-Folk'</td><td>73</td><td>'Acid Punk'</td></tr><tr><td>14</td><td>'R&amp;B'</td><td>34</td><td>'Acid'</td><td>54</td><td>'Eurodance'</td><td>74</td><td>'Acid Jazz'</td></tr><tr><td>15</td><td>'Rap'</td><td>35</td><td>'House'</td><td>55</td><td>'Dream'</td><td>75</td><td>'Polka'</td></tr><tr><td>16</td><td>'Reggae'</td><td>36</td><td>'Game'</td><td>56</td><td>'Southern Rock'</td><td>76</td><td>'Retro'</td></tr><tr><td>17</td><td>'Rock'</td><td>37</td><td>'Sound Clip'</td><td>57</td><td>'Comedy'</td><td>77</td><td>'Musical'</td></tr><tr><td>18</td><td>'Techno'</td><td>38</td><td>'Gospel'</td><td>58</td><td>'Cult'</td><td>78</td><td>'Rock &amp; Roll'</td></tr><tr><td>19</td><td>'Industrial'</td><td>39</td><td>'Noise'</td><td>59</td><td>'Gangsta'</td><td>79</td><td>'Hard Rock'</td></tr><TR><TD COLSPAN=8>Any other value should be considered as 'Unknown'</table><br></CENTER><p align="center"><a name="MPEG TAG"><font size="5"><b>MPEG AudioTag MP3v2</b></font><P>This is new proposed TAG format which is different than MP3v1 and MP3v1.1.Complete tech specs for it may be found at <A HREF="http://www.id3.com/">http://www.id3.com/</A>.<P><CENTER><hr><font size="2">Created on September 1998. by <A HREF="http://www.dv.co.yu/broker/">Predrag Supurovic</A>.<BR> Thanks to <A HREF="http://www.jps.net/kyunghi/">Jean Nicolle</A> for debugging and polishing of this document.<P>This document may be changed. Check <AHREF="http://www.dv.co.yu/mp3list/mpeghdr.htm">http://www.dv.co.yu/mp3list/mpeghdr.htm</A>for updates.<BR>You may use it freely. If you can help us make it more accurate, please do.</font></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -