做服装商城网站,问题谁负责,计算机应用技术毕业设计,平台式网站模板1. 概述现在很多智能手机都支持多媒体功能#xff0c;特别是音频和视频播放功能#xff0c;而3GP文件格式是手机端普遍支持的视频文件格式。目前很多手机都支持h263视频编码格式的视频文件播放#xff0c;还有些手机支持h264。音频文件格式普遍支持amr#xff0c;有些手… 1. 概述现在很多智能手机都支持多媒体功能特别是音频和视频播放功能而3GP文件格式是手机端普遍支持的视频文件格式。目前很多手机都支持h263视频编码格式的视频文件播放还有些手机支持h264。音频文件格式普遍支持amr有些手机还支持AAC音频格式。鉴于凤凰卫视节目主要以新闻类为主音频压缩采用AMR标准视频压缩采用H263和H264标准。编号 文件名 文件长度 时长 1 news_h263.3gp 1.38MB 01:21.90 2 zbc1217_h263.3gp 1.92MB 02:37.98 3 zbc1217_h264.3gp 2.44MB 02:37.98 2. 3GP文件结构分析示例AtomicParsley是一个开源的多媒体文件结构分析器。下面是用该程序分析的两个3GP文件结构news_h263.3gpAtom ftyp 0 of size: 28, ends 28Atom mdat 28 of size: 65, ends 93Atom mdat 93 of size: 130856, ends 130949Atom mdat 130949 of size: 1312119, ends 1443068Atom moov 1443068 of size: 7136, ends 1450204Atom mvhd 1443076 of size: 108, ends 1443184Atom trak 1443184 of size: 1546, ends 1444730Atom tkhd 1443192 of size: 92, ends 1443284Atom udta 1443284 of size: 48, ends 1443332Atom uuid484d496e-6354-7261-636b-496e666f2020 1443292 of size: 40, ends 1443332Atom mdia 1443332 of size: 1398, ends 1444730Atom mdhd 1443340 of size: 32, ends 1443372Atom hdlr 1443372 of size: 37, ends 1443409Atom minf 1443409 of size: 1321, ends 1444730Atom smhd 1443417 of size: 16, ends 1443433Atom dinf 1443433 of size: 36, ends 1443469Atom dref 1443441 of size: 28, ends 1443469Atom stbl 1443469 of size: 1261, ends 1444730Atom stts 1443477 of size: 24, ends 1443501Atom stsd 1443501 of size: 69, ends 1443570Atom samr 1443517 of size: 53, ends 1443570Atom damr 1443553 of size: 17, ends 1443570Atom stsz 1443570 of size: 1112, ends 1444682Atom stsc 1444682 of size: 28, ends 1444710Atom stco 1444710 of size: 20, ends 1444730Atom trak 1444730 of size: 5474, ends 1450204Atom tkhd 1444738 of size: 92, ends 1444830Atom tref 1444830 of size: 20, ends 1444850Atom sync 1444838 of size: 12, ends 1444850Atom udta 1444850 of size: 48, ends 1444898Atom uuid484d496e-6354-7261-636b-496e666f2020 1444858 of size: 40, ends 1444898Atom mdia 1444898 of size: 5306, ends 1450204Atom mdhd 1444906 of size: 32, ends 1444938Atom hdlr 1444938 of size: 37, ends 1444975Atom minf 1444975 of size: 5229, ends 1450204Atom vmhd 1444983 of size: 20, ends 1445003Atom dinf 1445003 of size: 36, ends 1445039Atom dref 1445011 of size: 28, ends 1445039Atom stbl 1445039 of size: 5165, ends 1450204Atom stts 1445047 of size: 24, ends 1445071Atom stsd 1445071 of size: 117, ends 1445188Atom s263 1445087 of size: 101, ends 1445188Atom d263 1445173 of size: 15, ends 1445188Atom stsz 1445188 of size: 4920, ends 1450108Atom stss 1450108 of size: 48, ends 1450156Atom stsc 1450156 of size: 28, ends 1450184Atom stco 1450184 of size: 20, ends 1450204------------------------------------------------------Total size: 1450204 bytes; 46 atoms total. AtomicParsley version: 0.9.0 (utf16)Media data: 1442975 bytes; 7229 bytes all other atoms (0.498% atom overhead).Total free atom space: 0 bytes; 0.000% waste.------------------------------------------------------Movie duration: 81.900 seconds (01:21.90) - 140.95* kbp/sec bitrate (*approximate)Low-level details. Total tracks: 2Trk Type Handler Kind Lang Bytes1 soun soun samr eng 130848 Encoder: NXTR12.78* kbp/s 81.900 sec AMR Narrow-Band.Modes: 0, 1, 2, 3, 4, 5, 6, 7, 8. Encoder vendor code: NXTR2 vide vide s263 eng 1312111 Encoder: NXTR128.41* kbp/s 81.748 sec H.263 Baseline Profile, Level 10. Encoder vendor code: NXTR该3GP文件结构如下 zbc1217_h263.3gpAtom ftyp 0 of size: 24, ends 24Atom mdat 24 of size: 1989236, ends 1989260Atom moov 1989260 of size: 14951, ends 2004211Atom mvhd 1989268 of size: 108, ends 1989376Atom iods 1989376 of size: 33, ends 1989409Atom udta 1989409 of size: 1069, ends 1990478Atom rtng [eng] 1989417 of size: 29, ends 1989446Atom uuidf78caa0c-36be-4ce9-88d2-03c256dabeb2 1989446 of size: 1032, ends 1990478Atom trak 1990478 of size: 9978, ends 2000456Atom tkhd 1990486 of size: 92, ends 1990578Atom mdia 1990578 of size: 9842, ends 2000420Atom mdhd 1990586 of size: 32, ends 1990618Atom hdlr 1990618 of size: 33, ends 1990651Atom minf 1990651 of size: 9769, ends 2000420Atom vmhd 1990659 of size: 20, ends 1990679Atom dinf 1990679 of size: 36, ends 1990715Atom dref 1990687 of size: 28, ends 1990715Atom stbl 1990715 of size: 9705, ends 2000420Atom stsd 1990723 of size: 117, ends 1990840Atom s263 1990739 of size: 101, ends 1990840Atom d263 1990825 of size: 15, ends 1990840Atom stts 1990840 of size: 32, ends 1990872Atom stsc 1990872 of size: 1900, ends 1992772Atom stsz 1992772 of size: 6300, ends 1999072Atom stco 1999072 of size: 644, ends 1999716Atom stss 1999716 of size: 704, ends 2000420Atom udta 2000420 of size: 36, ends 2000456Atom uuidf78caa0c-36be-4ce9-87d2-03c256dabeb2 2000428 of size: 28, ends 2000456Atom trak 2000456 of size: 2934, ends 2003390Atom tkhd 2000464 of size: 92, ends 2000556Atom mdia 2000556 of size: 2798, ends 2003354Atom mdhd 2000564 of size: 32, ends 2000596Atom hdlr 2000596 of size: 33, ends 2000629Atom minf 2000629 of size: 2725, ends 2003354Atom smhd 2000637 of size: 16, ends 2000653Atom dinf 2000653 of size: 36, ends 2000689Atom dref 2000661 of size: 28, ends 2000689Atom stbl 2000689 of size: 2665, ends 2003354Atom stsd 2000697 of size: 69, ends 2000766Atom samr 2000713 of size: 53, ends 2000766Atom damr 2000749 of size: 17, ends 2000766Atom stts 2000766 of size: 24, ends 2000790Atom stsc 2000790 of size: 1900, ends 2002690Atom stsz 2002690 of size: 20, ends 2002710Atom stco 2002710 of size: 644, ends 2003354Atom udta 2003354 of size: 36, ends 2003390Atom uuidf78caa0c-36be-4ce9-87d2-03c256dabeb2 2003362 of size: 28, ends 2003390Atom trak 2003390 of size: 420, ends 2003810Atom tkhd 2003398 of size: 92, ends 2003490Atom mdia 2003490 of size: 296, ends 2003786Atom mdhd 2003498 of size: 32, ends 2003530Atom hdlr 2003530 of size: 33, ends 2003563Atom minf 2003563 of size: 223, ends 2003786Atom nmhd 2003571 of size: 12, ends 2003583Atom dinf 2003583 of size: 36, ends 2003619Atom dref 2003591 of size: 28, ends 2003619Atom stbl 2003619 of size: 167, ends 2003786Atom stsd 2003627 of size: 67, ends 2003694Atom mp4s 2003643 of size: 51, ends 2003694Atom esds 2003659 of size: 35, ends 2003694Atom stts 2003694 of size: 24, ends 2003718Atom stsc 2003718 of size: 28, ends 2003746Atom stsz 2003746 of size: 20, ends 2003766Atom stco 2003766 of size: 20, ends 2003786Atom tref 2003786 of size: 24, ends 2003810Atom mpod 2003794 of size: 16, ends 2003810Atom trak 2003810 of size: 401, ends 2004211Atom tkhd 2003818 of size: 92, ends 2003910Atom mdia 2003910 of size: 301, ends 2004211Atom mdhd 2003918 of size: 32, ends 2003950Atom hdlr 2003950 of size: 33, ends 2003983Atom minf 2003983 of size: 228, ends 2004211Atom nmhd 2003991 of size: 12, ends 2004003Atom dinf 2004003 of size: 36, ends 2004039Atom dref 2004011 of size: 28, ends 2004039Atom stbl 2004039 of size: 172, ends 2004211Atom stsd 2004047 of size: 72, ends 2004119Atom mp4s 2004063 of size: 56, ends 2004119Atom esds 2004079 of size: 40, ends 2004119Atom stts 2004119 of size: 24, ends 2004143Atom stsc 2004143 of size: 28, ends 2004171Atom stsz 2004171 of size: 20, ends 2004191Atom stco 2004191 of size: 20, ends 2004211------------------------------------------------------Total size: 2004211 bytes; 82 atoms total. AtomicParsley version: 0.9.0 (utf16)Media data: 1989236 bytes; 14975 bytes all other atoms (0.747% atom overhead).Total free atom space: 0 bytes; 0.000% waste.------------------------------------------------------Movie duration: 156.980 seconds (02:36.98) - 101.38* kbp/sec bitrate (*approximate)Low-level details. Total tracks: 4Trk Type Handler Kind Lang Bytes1 vide [none listed] s263 und 1738018 Encoder: ViVi88.58* kbp/s 156.960 sec H.263 Baseline Profile, Level 20. Encoder vendor code: ViVi2 soun [none listed] samr und 251168 Encoder: ViVi12.80* kbp/s 156.980 sec AMR Narrow-Band. Modes: 7. Encoder vendor code: ViVi3 odsm [none listed] mp4s und 184 sdsm [none listed] mp4s und 24该3GP文件结构如下其实3GP文件就是一个对象box容器对象还允许包含子对象。 对象格式如下 struct { UINT32size; //对象大小 chartype; //对象类型 void*data; //对象数据属性大小为(size-8) }; 《ISO base media file format》说明不同box对象的结构定义细节。3. 3GP文件对象实例分析l ftypeFile Type该对象仅有一个记录该文件使用的规范和版本等信息。属性 大小 值 说明 size 4 0x0000001c 28 ftyp 4 ftyp major_brand 4 3gp4 主类型 minor_version 4 最小版本号 compatible_brands[] string 3gp4 | 3gp5 | 3g2a 兼容类型 l mdatMedia Datamdat 存放媒体数据media data。一般包括文字、音频和视频等。这些mdat的顺序不固定。当前mdat对象包含的是纯文字。大小 值 其他说明 size 4 0x00000041 65 mdat 4 string
这个box可以忽略。l mdat音频数据块大小 值 其他说明 size 4 0x0001FF28 130856 mdat 4 32*N 3C打头 每个音频帧32字节 amr音频数据以32字节一帧每帧20毫秒。所以根据amr数据包大小就能估算出语音的时间长度。 (130856– 8) / 32 4089 * 20 81780 ms 817.80秒 01:21.90 这个时间与播放器上显示的时间基本相同。 注意这里真实的视频数据起始位置为0x000005D。 在音频trak里面的stso对象里面的chunk_offset记录的就是这个值。 在RFC3267中有如下描述 The sampling frequency used in AMR is 8000 Hz and the speech encoding is performed on 20 ms speech frames. Therefore, each encoded AMR speech frame represents 160 samples of the original speech. AMR语音采样频率为8Khz每帧对应20ms。 l mdat 视频数据块 大小 值 其他说明 size 4 0x004946F1 4802289 mdat 4 4 H263视频数据 实际视频数据大小4802289 – 8 4802281 《H263协议中文版》第8页 5.1图象层中描述 每帧图象的数据包含一个图象头并紧跟着块组数据最后是一个end-of-sequence码和填塞位。 图象开始码 (PSC) (22 bits) PSC是一个22比特的字。它的值是0000 0000 0000 0000 1000 00- 00 00 80 00 …z 时域参考 (TR) (8 bits) 00-00 000000- 类型信息 (PTYPE) (13 bits) 00-10 0000 1000 000-0 位6-8010表示图像为QCIF。 位9图象编码类型“0” INTRA (I-picture)“1” INTER (P-picture)。关键帧标志位0关键帧1p帧。 l moov Movie Box 该对象保留了3GP视频的metadata即该3GP的全部描述信息。 这个对象一般在文件开始或者末尾。 下面详细分析moov的各个子对象。 l mvhd Movie Head Box 大小 值 其他说明 size 4 0x0000006C 108 mvhd 4 version 1 0 flag 3 0 creation_time 4 modification_time 4 timescale 4 0x000003E8 1000 时间缩放因子 duration 4 0x00013FEC 81900 81.9s 持续时间 rate 4 0x00010000 1.0即全速播放 播放比率 volume 2 0x0100 1.0 音量 音量 reserved 保留 reserved 保留 matrix 视频转换矩阵 pre_defined 预定义(全0) next_track_ID 4 0x000000CA 202 下一个track_id trak(音频) Track Box l tkhd Track Header Box 定义了该track的属性。 大小 值 其他说明 size 4 0x0000005C 92 tkhd 4 version 1 0 flag 3 1 creation_time 4 modification_time 4 track_id 4 0x00000065 101 reserved 4 全0 duration 4 0x00013FEC 81900 81.9s 音频播放时间 reserved 8 layer 2 alternate_group 2 volume 2 0x0100 如果track是音频则为0x0100视频则为0x0000。 reserved 2 0 matrix 4 * 9 视频转换矩阵 width 4 0 音频的w和h为0 height 4 0 注意如果track是音频volume则为0x0100视频volume则为0x0000。 l mdhd Media Header Box 大小 值 其他说明 size 4 32 mdhd 4 version 1 flag 3 creation_time 4 modification_time 4 timescale 4 0x00001F40 8000 时间缩放因子 duration 4 0x0009FF60 655200/800081.9 音频播放时长 pad 1bit language 15bit 0x15c7 ISO-639-2/T language code pre_defined 2 l hdlr Handler Reference Box 大小 值 其他说明 size 4 0x00000025 37 hdlr 4 version 1 flag 3 pre_defined 4 0 handler_type 4 soun videVideo track sounAudio track reserved 4 * 3 0 handler_type string 41 soun 以’/0’结束 l stbl Sample Table Box l stts Decoding Time to Sample Box 大小 值 其他说明 size 4 0x00000018 24 stts 4 version 1 flag 3 entry_count 4 1 sample_count 4 0x00000111 273 sample_delta 4 0x00000960 2400 说明该amr音频数据里面有273个sample每个sample的时间为2400而音频的时间因子为8000见5.2.3.1 mdhd的timescale所以每个sample的时长 2400 / 8000s 0.3s。 l stsd Sample Description Box 大小 值 其他说明 size 4 0x00000045 69 stsd 4 version 1 flag 3 entry_count 4 1 AudioSampleEntry l samr amr音频 size 4 0x35 53 samr 4 reserved 6 0 data_reference_index 2 0x0001 reserved 4 * 2 0 channelcount 2 0x0002 2 (1:单声道 2:双声道) samplesize 2 0x0010 16 pre_defined 2 0 reserved 2 0 samplerate 4 0x1F400000 (14F0)16 0x1F40 8000 时间因子左移16位。 声音采样频率hz size 4 0x11 17 damr 4 NXTR ... 9 l stsz Sample Size Boxes 大小 值 其他说明 size 4 0x00000458 1112 stsz 4 version 1 flag 3 sample_size 4 0 sample_count 4 0x00000111 273 entry_size 4 0x000001E0 480 每个sample大小 4 0x000001E0 480 4 0x000001E0 480 ... 说明在5.2.3.3.3.1 stts中说明了有1001个sample这里的sample_count1001每个sample数据块的大小为480480 / 32*20 15*20 0.3s。 这里包含了每个sample的大小都为480字节。 l stsc Sample To Chunk Box 大小 值 其他说明 size 4 0x0000001C 28 stsc 4 version 1 flag 3 entry_count 4 1 first_chunk 4 1 samples_per_chunk 4 0X0111 273 sample_description_index 4 1 l stco Chunk Offset Box 大小 值 其他说明 size 4 0x00000014 20 stco 4 version 1 flag 3 entry_count 4 1 chunk_offset 4 0x65 101 trak(视频) Track Box l tkhd Track Header Box 定义了该track的属性。 大小 值 其他说明 size 4 0x0000005C 92 tkhd 4 version 1 0 flag 3 1 creation_time 4 modification_time 4 track_id 4 0x000000C9 201 reserved 4 全0 duration 4 0x00013F54 81748 81.7s 视频播放时间 reserved 8 layer 2 alternate_group 2 volume 2 0x0000 如果track是音频则为0x0100视频则为0x0000。 reserved 2 0 matrix 4 * 9 视频转换矩阵 width 4 0x0140000016 0x0140320 height 4 0x00F0000016 0x00F0240 l vmhd Video Media Header Box 大小 值 其他说明 size 4 0x00000014 20 wmhd 4 version 1 flag 3 graphicsmode 2 0 opcolor 2 * 3 {0,0,0} l stts Sync Sample Box 大小 值 其他说明 size 4 0x00000018 24 stts 4 version 1 flag 3 entry_count 4 1 sample_count 4 0x000004C9 1225 sample_delta 4 0x00001776 6006 说明该H263视频数据里面有1225个sample每个sample的时间为6006而视频的时间因子为90000见5.3.3.1 mdhd的timescale所以每个sample的时长 6006 / 90000s 0.0667s。 1225*6006 / 90000 1225*6006/90000 81.7s l stsd Sample Description Box 大小 值 其他说明 size 4 0x00000075 117 stsd 4 stsd version 1 0 flag 3 0 entry_count 4 1 VideoSampleEntry l S263 263视频 size 4 0x65 101 s263 4 reserved 6 data_reference_index 2 0x0001 pre_defined 2 0 reserved 2 0 pre_defined 4 * 3 width 2 0xb0 176 视频宽度 height 2 0x90 144 视频高度 horizresolution 4 0x00480000; // 72 dpi vertresolution 4 0x00480000; // 72 dpi reserved 4 frame_count 2 1 compressorname 32 string[32] 全0 depth 2 0x0018 pre_defined 2 -1 size 4 15 d263 4 NXTR ... 7 l stsz Sample Size Boxes 大小 值 其他说明 size 4 0x1338 stsz 4 version 1 flag 3 sample_size 4 0 sample_count 4 0x04C9 1225 entry_size 4 0x0000297 663 4 0x068C 1676 4 0x028D 653 ... 说明总共1225个sample即有1225帧sample_count后面紧跟的是每个视频帧的数据大小可以看出每个帧的大小都不一样这是因为视频帧的类型不同有些帧是I帧有些是P帧有些是B帧。 MPEG图像编码包含3个成分I帧P帧和B帧。MPEG编码过程中一些图像压缩成I帧一些压缩成P帧另一些压缩成B帧。I帧压缩可以得到61的压缩比而不产生任何可觉察的模糊现象。I帧压缩的同时使用P帧压缩可以达到更高的压缩比而无可觉察的模糊现象。B帧压缩可以达到2001的压缩比其文件尺寸一般为I帧压缩尺寸的15%不到P帧压缩尺寸的一半。I帧压缩去掉图像的空间冗余度P帧和B帧去掉时间冗余度下文将进一步解释。 I帧压缩采用基准帧模式只提供帧内压缩即把帧图像压缩到I帧时仅仅考虑了帧内的图像。I帧压缩不能除去帧间冗余度。帧内压缩基于离散余弦变换DCT类似于JPEG和H.261图像中使用DCT的压缩标准。 P帧采用预测编码利用相邻帧的一般统计信息进行预测。也就是说它考虑运动特性提供帧间编码。P帧预测当前帧与前面最近的I帧或P帧的差别。 B帧为双向帧间编码。它从前面和后面的I帧或P帧中提取数据。B帧基于当前帧与前一帧和后一帧图像之间的差别进行压缩。 MEPG数据流开始时对CCIR-601规定的SIF分辨率的未压缩数字图像进行抽样。SIF分辨率对于NTSC制就是亮度信号为352240各像素每个色度信号都为176120个象素。各信号都是每秒30帧。MPEG压缩器决定了当前帧以I帧P帧还是B帧。帧确定之后就采用DCT变换对结果进行量化舍入行程编码即变长编码。编码后的典型图像帧序为IBBPBBPBBPBBIBBPBBPBBPBBI… B帧和P帧要求计算机有更强的功能。有些压缩器不能产生B帧或者连P帧也不能产生则图像的压缩结果将有很明显的间断。 H263采用了与MPEG相似的技术。 l stco Chunk Offset Box 大小 值 其他说明 size 4 0x00000014 20 stco 4 version 1 flag 3 entry_count 4 1 chunk_offset 4 0x0001FF8D 说明chunk_offset定义的是视频数据的起始位置。