从网络上收集了大量的资料后进行验证。很多都不行
有源码最好,给个理论的解释也行。

解决方案 »

  1.   

    用Lame, 底层有函数实现的。只是没有导出。
    加个头导出即可。
    给个Mail, 可以发给你。
      

  2.   

    struct Header
    {
    unsigned short sync:11;
    unsigned short version:2;
    unsigned short lay:2;
    unsigned short error_protection:1;
    unsigned short bitrate_index:4;
    unsigned short sampling_freq:2;
    unsigned short padding:1;
    unsigned short extension:1;
    unsigned short mode:2;
    unsigned short mode_ext:2;
    unsigned short copyright:1;
    unsigned short orginal:1;
    unsigned short emphasis:2;
    }Header;    struct Tail
    {
    char tag[3];
    char title[30];
    char artist[30];
    char album[30];
    char year[4];
    char comments[30];
    byte genre;
    }Tail;
    memset(&Header,0,sizeof(Header));
    memset(&Tail,0,sizeof(Tail)); CFile fp;
    fp.Open("c:\\a.mp3",CFile::modeRead);
    fp.Read(&Header,sizeof(Header));
    fp.SeekToBegin();
    fp.Seek(fp.GetLength()-sizeof(Tail),0);
    fp.Read(&Tail,sizeof(Tail));
    fp.Close();
    如上  
    ---------------------------------------------------------------  
     
    Mpeg  1.0/2.0  LayersI,  II  and  III  header  and  trailer  formats  
    -----------------------------------------------------------  
     
    [email protected]  
    With  corrections  by  Fausto  Richetti  Blanco  
     
     
     
    *  HEADER  
     
     
    bits  name                            comments  
    --------------------------------------------------  
    11      sync                            0xFFF  
    2        version                      1=mpeg1.0,  0=mpeg2.0  
    2        lay                              4-lay  =  layerI,  II  or  III  
    1        error  protection    0=yes,  1=no  
    4        bitrate_index          see  table  below  
    2        sampling_freq          see  table  below  
    1        padding  
    1        extension                  see  table  below  
    2        mode                            see  table  below  
    2        mode_ext                    used  with  "joint  stereo"  mode  
    1        copyright                  0=no  1=yes  
    1        original                    0=no  1=yes  
    2        emphasis                    see  table  below  
    --------------------------------------------------  
     
    -  bitrate_index  
     
    .  mpeg1.0  
     
                           1    2    3      4      5      6      7      8      9    10    11    12    13    14  
    layer1          32  64  96  128  160  192  224  256  288  320  352  384  416  448  
    layer2          32  48  56    64    80    96  112  128  160  192  224  256  320  384  
    layer3          32  40  48    56    64    80    96  112  128  160  192  224  256  320  
     
    .  mpeg2.0  
     
                           1    2    3      4      5      6      7      8      9    10    11    12    13    14  
    layer1          32  48  56    64    80    96  112  128  144  160  176  192  224  256  
    layer2            8  16  24    32    40    48    56    64    80    96  112  128  144  160  
    layer3            8  16  24    32    40    48    56    64    80    96  112  128  144  160  
     
     
    -  sampling_freq  
     
    .  mpeg1.0  
     
           0          1          2            
     
    44100  48000  32000    
     
    .  mpeg2.0  
     
           0          1          2            
     
    22050  24000  16000    
     
     
    -  mode:  
     
    0  "stereo"  
    1  "joint  stereo"  
    2  "dual  channel"  
    3  "single  channel"  
     
     
    -  mode  extension:  
       
    0            MPG_MD_LR_LR  
    1            MPG_MD_LR_I  
    2            MPG_MD_MS_LR    
    3            MPG_MD_MS_I  
     
    jsbound  :  
     
         mode_ext          0    1      2      3  
    layer  
    1                              4    8    12    16  
    2                              4    8    12    16  
    3                              0    4      8    16  
     
     
    -  emphasis:  
     
    0  "none"  
    1  "50/15  microsecs"  
    2  "reserved"                        must  not  be  used  !  
    3  "CCITT  J  17"  
     
     
     
     
    *  TRAILER  
     
    at  end  of  file  -  128  bytes  
     
    offset    type    len      name  
    --------------------------------------------  
    0              char    3                                      "TAG"  
    3              char    30        title  
    33            char    30        artist  
    63            char    30        album  
    93            char    4          year  
    97            char    30        comments  
    127          byte    1          genre  
    --------------------------------------------  
     
    -  genre  :  
     
     0        "Blues"  
     1        "Classic  Rock"  
     2        "Country"  
     3        "Dance"  
     4        "Disco"  
     5        "Funk"  
     6        "Grunge"  
     7        "Hip-Hop"  
     8        "Jazz"  
     9        "Metal"  
    10        "New  Age"  
    11        "Oldies"  
    12        "Other"  
    13        "Pop"  
    14        "R&B"  
    15        "Rap"  
    16        "Reggae"  
    17        "Rock"  
    18        "Techno"  
    19        "Industrial"  
    20        "Alternative"  
    21        "Ska"  
    22        "Death  Metal"  
    23        "Pranks"  
    24        "Soundtrack"  
    25        "Euro-Techno"  
    26        "Ambient"  
    27        "Trip-Hop"  
    28        "Vocal"  
    29        "Jazz+Funk"  
    30        "Fusion"  
    31        "Trance"  
    32        "Classical"  
    33        "Instrumental"  
    34        "Acid"  
    35        "House"  
    36        "Game"  
    37        "Sound  Clip"  
    38        "Gospel"  
    39        "Noise"  
    40        "AlternRock"  
    41        "Bass"  
    42        "Soul"  
    43        "Punk"  
    44        "Space"  
    45        "Meditative"  
    46        "Instrumental  Pop"  
    47        "Instrumental  Rock"  
    48        "Ethnic"  
    49        "Gothic"  
    50        "Darkwave"  
    51        "Techno-Industrial"  
    52        "Electronic"  
    53        "Pop-Folk"  
    54        "Eurodance"  
    55        "Dream"  
    56        "Southern  Rock"  
    57        "Comedy"  
    58        "Cult"  
    59        "Gangsta"  
    60        "Top  40"  
    61        "Christian  Rap"  
    62        "Pop/Funk"  
    63        "Jungle"  
    64        "Native  American"  
    65        "Cabaret"  
    66        "New  Wave"  
    67        "Psychadelic"  
    68        "Rave"  
    69        "Showtunes"  
    70        "Trailer"  
    71        "Lo-Fi"  
    72        "Tribal"  
    73        "Acid  Punk"  
    74        "Acid  Jazz"  
    75        "Polka"  
    76        "Retro"  
    77        "Musical"  
    78        "Rock  &  Roll"  
    79        "Hard  Rock"  
    80        "Unknown"  
     
     
     
    -  frame  length  :  
     
    .  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  
      

  3.   

    MP3幀頭數據長度為4字節,下面是定位MP3幀頭的函數BOOL FindHeader(const void *const headerptr)
    {
        const unsigned char *const p = headerptr;
        static const char abl2[16] =
    { 0, 7, 7, 7, 0, 7, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8 };

        if ((p[0] & 0xFF) != 0xFF)
            return FALSE;       /* first 8 bits must be '1' */
        if ((p[1] & 0xE0) != 0xE0)
            return FALSE;       /* next 3 bits are also */
        if ((p[1] & 0x18) == 0x08)
            return FALSE;       /* no MPEG-1, -2 or -2.5 */
        if ((p[1] & 0x06) == 0x00)
            return FALSE;       /* no Layer I, II and III */
        if ((p[2] & 0xF0) == 0xF0)
            return FALSE;       /* bad bitrate */
        if ((p[2] & 0x0C) == 0x0C)
            return FALSE;       /* no sample frequency with (32,44.1,48)/(1,2,4)     */
        if ((p[1] & 0x18) == 0x18 && (p[1] & 0x06) == 0x04
    && abl2[p[2] >> 4] & (1 << (p[3] >> 6)))
    return FALSE;
        if ((p[3] & 3) == 2)
    return FALSE;       /* reserved enphasis mode */
        return TRUE;
    }
      

  4.   

    幀頭各項數據含義如 howtotell(从何谈起) 所說
    ID3v1佔用文件末尾128字節,ID3v2載文件首部,長度不定
      

  5.   

    howtotell 结构我手里有,就是这个结构对特殊的Mp3格式异常。
    其他的测试中。
      

  6.   

    你可以使用下面网站提供的免费的MP3开发包。
    http://www.24bc.com/NewPoint.htm