GOP的两种结构
MPEG的格式支持open GOP或者close GOP格式。Close GOP是指帧间的预测都是在GOP中进行的。而使用open GOP,后一个GOP会参考前一个GOP的信息。使用这种方式就大大降低了码率。
Close-GOP
By definition, closed GOPs cannot contain any frame that refers to a frame in the previous or next GOP.
closed GOP中的帧不可以参考其前后的其它GOP.
Closed GOPs created by Compressor always begin with an I-frame.
Closed GOP一般以I帧开头。
Open-GOP
Open-GOP:informal structure. 在一个GOP里面的某一帧在解码时要依赖于前一个GOP中的某一些帧,这种GOP结构叫做Open-GOP。一般码流里面含有B帧的时候才会出现Open-GOP。
Open GOPs are most efficient because they allow an extra B-frame in the GOP pattern.
Open GOPs start with a B-frame that is able to look at the last P-frame from the preceding GOP as well as the first I-frame of its own GOP.
open GOPs begin with one or more B-frames that reference the last P-frame of the previous GOP.
Open GOP以一个或多个B帧开始,参考之前GOP的P帧和当前GOP的I帧。
Open GOPs generally provide slightly better compression than do closed GOPs of the same structure and size.
The illustration above shows that a closed GOP contains one more P-frame than does an open GOP of the same length. Since P-frames generally require more bits than do B-frames, the open GOP achieves slightly better compression.
同等条件下,Open GOP比closed GOP具有更高的压缩效率。
总结一句话: 判断码流是否open gop,可以通过以下的逻辑来判断:
B帧在I帧之后解码 但是在I帧之前显示。
H264中的I帧
主要有2种I帧:I(IDR帧)、I(非IDR I帧)。
I(IDR帧)
NALU_type = 0x65。
IDR帧是一种特殊的I帧,在解码IDR帧前,清空所有前后向参考缓冲区,IDR帧随后的所有帧不能参考IDR前面的任何帧。
IDR帧是视频安全的随机访问点,找到一个IDR帧可以丢弃前面所有帧数据而正确解码。
I(非IDR帧)
NALU_type = 0x61。
i帧是帧内预测帧,它的解码不依赖与任何其他帧。
区别
有些解码器没有区分这两种I帧,将所有的i帧都缺省的认为是IDR帧,这样会造成解码错误。
这两种i帧在open-GOP的结构中需要明确区分,而在close-GOP中可以视为相同。
Reference:
https://blog.csdn.net/soaringlee_fighting/article/details/79650820
https://blog.csdn.net/aokewood/article/details/6893699
http://www.360doc.com/content/12/0108/11/7923573_178053426.shtml
https://documentation.apple.com/en/compressor/usermanual/index.html#chapter=18%26section=5%26tasks=true
https://compressor-4.helpnox.com/en-us/compressor-4-user-manual/creating-mpeg-2-output-files/mpeg-2-reference-information/things-to-consider-when-choosing-a-gop-setting/open-and-closed-gops/
https://blog.csdn.net/yue_huang/article/details/73432141