MPEG-4码流简析

如何判断码流的编码格式为MPEG-4

可通过查看第一个数据包的payload前几个字节:
如果是 0x00 0x00 0x01 0xB0, 则当前码流可能是MPEG-4码流。

判断MPEG-4码流的简易方法

或者观察后续的是否存在多个以0x00 0x00 0x01 0xB6开头的数据包,也可以来进行判断。

基本概念

Visual object sequence

Visual object sequence is the highest syntactic structure of the coded visual bitstream.
A visual object sequence commences with a visual_object_sequence_start_code which is followed by one or more
visual objects coded concurrently
.
The visual object sequence is terminated by a visual_object_sequence_end_code.

**VisualObjectSequence()**

Visual object

A visual object commences with a visual_object_start_code, is followed by profile and level identification, and a
visual object id, and is followed by a video object, a still texture object, a mesh object, or an FBA object.


**Visual object的前半部分**
Video object

A video object commences with a video_object_start_code, and is followed by one or more video object layers.

VOP

VOP (Video Object Plane -- frame) starts with a code 000001B6(hex). It is the same for all MPEG4 frames (I,P,B)

VOP可理解为帧的概念,有I-VOPP-VOP等。

VOP

MPEG-4整体层次

MPEG-4整体层次

References:http://blog.csdn.net/joesay/article/details/4988575

startcode

Start code values

As far as I know, MPEG4-ES stream fragments in RTP payload usually start with MPEG4 startcode, which can be one of these:
0x000001b0: visual_object_sequence_start_code (probably keyframe)
0x000001b6: vop_start_code (keyframe, if the next two bits are zero)
0x000001b3: group_of_vop_start_code, which contains three bytes and then hopefully a vop_start_code that may or may not belong to a keyframe (see above)
0x00000120: video_object_layer_start_code (probably keyframe)
0x00000100-0x0000011f: video_object_start_code (those look like keyframes as well)
something else (probably not a keyframe)

0x000001b0

visual_object_sequence_start_code, visual_object_sequence序列的startcode。
码流的第一个数据包也以此为开头。
码流中可能存在多个visual_object_sequence_start_code(因为可能存在多个sequence)。

0x000001b6

vop_start_code: This is the bit string ‘000001B6’ in hexadecimal. It marks the start of a video object plane.

即VOP(可理解为一帧)的startcode。

为什么会出现多个连续的开头无任何规律的数据包

比如在某数据包出现0x00 0x00 0x01 0xb0(或0x00 0x00 0x01 0xb6)之后, 后续的数据包开头无任何规律,这是为什么呢?
这是因为他们都属于同一帧的数据
他们拥有相同的时间戳,所以属于同一帧的数据。

**payload以0x000001b0开头的数据包**
**payload开头无规律的数据包**

如何判断I-VOP和P-VOP

答案是: 由0x00 0x00 0x01 0xb6之后的两位决定。

**VideoObjectPlane() 的前半部分**

vop_coding_type

vop_coding_type的值如果为00,则为I-VOP
vop_coding_type的值如果为01,则为P-VOP

References:

ISO/IEC 14496-2:2001(E)
http://blog.csdn.net/sunnylgz/article/details/7745038
http://stackoverflow.com/questions/1957427/detect-mpeg4-h264-i-frame-idr-in-rtp-stream
http://users.ece.utexas.edu/~bevans/courses/ee381k/lectures/12_Video_Coding/lecture12/sld008.htm
http://blog.csdn.net/axdc_qa_team/article/details/4042762
http://blog.csdn.net/joesay/article/details/4988575

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容