请教mp3文件格式

园区宅男 2003-11-18 03:35:08
mp3文件是音乐文件,这个我知道。

它也跟bmp文件一样类似有头文件,数据部分等等吗?
以及文件的作者,版权什么的好像都在文件中。

请详解!
...全文
631 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
daizh 2003-11-18
  • 打赏
  • 举报
回复

Mpeg 1.0/2.0 LayersI, II and III header and trailer formats
-----------------------------------------------------------

Laurent.Clevy@alcatel.fr



* HEADER


bits name comments
--------------------------------------------------
12 sync 0xFFF
1 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
winco 2003-11-18
  • 打赏
  • 举报
回复
奶油狗加的注释
typedef struct
{
// 下面有些和In_Module一样,就不赘述了。
int nVer;
char *szDesc;
int nId; // 自己给一个ID,不知道有什么用,反正大于65536就行了。
HWND hMainWindow;
HINSTANCE hDllInstance;
void (*Config)(HWND hwndParent);
void (*About)(HWND hwndParent);
void (*Init)();
void (*Quit)();
// nSample - 采样率, nChannels - 声道数,1或2
// nBitPerSamp - 每采样的位率,nBufLen、nPreBufLen - 缓冲长度,咱们用不到
// 返回大于0正常播放,小于0失败
int (*Open)(int nSample, int nChannels, int nBitPerSamp, int nBufLen, int nPreBufLen);
void (*Close)(); // 关闭输出设备
// pBuf - 内存数据块,nLen - 数据块的长度
int (*Write)(char *pBuf, int len); // 返回0成功,其它不成功
int (*CanWrite)(); // 表示当前状态是否可写
int (*IsPlaying)(); // 表示是否正在播放
int (*Pause)(int pause); // 暂停,稍后详释
void (*SetVolume)(int volume);
void (*SetPan)(int pan);
void (*Flush)(int t); // 刷新缓冲
int (*GetOutputTime)(); // 获取输出时间
int (*GetWrittenTime)(); // 返回写入的时间
} Out_Module;


typedef struct
{
int nVer; // 模块版本号
char *szDesc; //模块描述信息
HWND hMainWnd; // Winamp的主窗体句柄(由Winamp来填写)
HINSTANCE hDllInstance; // DLL实例句柄(由Winamp来填写)
char *szFileExt; // 扩展名过滤器,格式参见GetOpenFileName
int nIsSeekable; // 是否可索引媒体,是-你可以拖动进度条,否-反之
int UsesOutputPlug; // 是否使用输出插件?你想在这个模块里搞定一切?

// 下面都是函数指针,将被Winamp调用
void (*Config)(HWND hwndParent); // 配置对话框
void (*About)(HWND hwndParent); // 关于对话框
void (*Init)(); // 初始化
void (*Quit)(); // 退出
// szFile - 传入的文件名,szTitle - 传出的标题,nLen - 转出的时间长度,毫秒。
// 如果szFile传NULL,则返回当前播放文件的信息
void (*GetFileInfo)(char *szFile, char *szTitle, int *nLen);
int (*InfoBox)(char *szFile, HWND hwndParent); // 弹出文件信息对话框
int (*IsOurFile)(char *szFile); // 检查文件格式
int (*Play)(char *szFile); // 开始播放文件szFile,返回0正常,-1错误
void (*Pause)(); // 暂停处理
void (*UnPause)(); // 取消暂停
int (*IsPaused)(); // 是否斩停?1是暂停,0不是
void (*Stop)(); // 停止播放
int (*GetLength)(); // 取得长度,毫秒单位
int (*GetOutputTime)(); // 获取当前时间,一般调用out模块的同名函数即可
void (*SetOutputTime)(int nTime); // 索引到某一时刻
void (*SetVolume)(int volume); // 音量调节,从0 - 255
void (*SetPan)(int pan); // 左右声道平衡,从-127 - 127

//下面的函数多和AVS、可视化效果、均衡器等有关,具体咱们用不到,就暂时不讲了。
void (*SAVSAInit)(int maxlatency_in_ms, int srate);
void (*SAVSADeInit)(); // call in Stop()
void (*SAAddPCMData)(void *PCMData, int nch, int bps, int timestamp);
int (*SAGetMode)();
void (*SAAdd)(void *data, int timestamp, int csa);
void (*VSAAddPCMData)(void *PCMData, int nch, int bps, int timestamp);
int (*VSAGetMode)(int *specNch, int *waveNch);
void (*VSAAdd)(void *data, int timestamp);
void (*VSASetInfo)(int nch, int srate);
int (*dsp_isactive)();
int (*dsp_dosamples)(short int *samples, int numsamples, int bps, int nch, int srate);
void (*EQSet)(int on, char data[10], int preamp);
void (*SetInfo)(int bitrate, int srate, int stereo, int synched);

Out_Module *outMod;
} In_Module;
敬告:该系列的课程在抓紧录制更新中,敬请大家关注。敬告: 该系列的课程涉及:FFmpeg,WebRTC,SRS,Nginx,Darwin,Live555,等。包括:音视频、流媒体、直播、Android、视频监控28181、等。  我将带领大家一起来学习:采集麦克风、PCM重采样、AAC或MP3音频编码存储、并直播。具体内容包括:1.FFmpeg采集麦克风并存储为PCM。2.PCM重采样原理及实战。3.采集麦克风并实时转码AAC或MP3并保存文件。4.采集麦克风并实时转码AAC并可以直播。 音视频与流媒体是一门很复杂的技术,涉及的概念、原理、理论非常多,很多初学者不学 基础理论,而是直接做项目,往往会看到c/c++的代码时一头雾水,不知道代码到底是什么意思,这是为什么呢? 因为没有学习音视频和流媒体的基础理论,就比如学习英语,不学习基本单词,而是天天听英语新闻,总也听不懂。所以呢,一定要认真学习基础理论,然后再学习播放器、转码器、非编、流媒体直播、视频监控、等等。 梅老师从事音视频与流媒体行业18年;曾在永新视博、中科大洋、百度、美国Harris广播事业部等公司就职,经验丰富;曾亲手主导广电直播全套项目,精通h.264/h.265/aac,曾亲自参与百度app上的网页播放器等实战产品。 目前全身心自主创业,主要聚焦音视频+流媒体行业,精通音视频加密、流媒体在线转码快编等热门产品。

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧