Log in

View Full Version : GOP analysis


leoenc
23rd April 2013, 08:31
Hi guys,

How does one tell if an x264 stream is closed GOP or open GOP?

Is there an analyzer that can detect that?

thanks

leo

leoenc
23rd April 2013, 10:17
Just to clarify, I don't mean reading the x264 header via MediaInfo, I mean actual analysis of the stream itself.
I ask because my stream is being rejected by a streaming server, claiming the GOP isn't closed (haven't used the --open-gop switch).

Warperus
23rd April 2013, 10:21
There was similar thread, may be you can find an answer there:
http://forum.doom9.org/showthread.php?t=133381

leoenc
23rd April 2013, 12:38
@Warperus
Thanks but that thread is about GOP structure. I tried some of the methods listed there but couldn't find any tool that can show whether GOPs are open or closed.

leoenc
23rd April 2013, 16:13
@paradoxial
AFAIK, every GOP, whether it's closed or open, must start with an I-frame. The GOP is considered closed if B-frames do not reference frames that reside on other GOPs.

paradoxical
23rd April 2013, 16:27
Yeah, that was obviously incorrect. I'm not thinking right this morning.

paradoxical
23rd April 2013, 16:31
Maybe this post (http://forum.doom9.org/showpost.php?p=1300124&postcount=32) might be helpful?

leoenc
23rd April 2013, 17:16
@paradoxial
Thanks but I'm not sure what to make of this. Also, manually looking for patterns in the GOP structure doesn't make sense. There must be some code that can scan the stream and output the result.
After all, the stream is being rejected by the streaming server with a "not closed GOP" error, which means it is doing that scan, right?

paradoxical
23rd April 2013, 18:06
Also, manually looking for patterns in the GOP structure doesn't make sense.

Who said anything about doing it manually?

There must be some code that can scan the stream and output the result.
After all, the stream is being rejected by the streaming server with a "not closed GOP" error, which means it is doing that scan, right?

Yes, there is probably code that scans the GOP structures in the stream to determine if it's an open or closed GOP. I would guess it's some combination of checking if an IDR frame precedes the B-frames in the GOP, as an IDR would prevent the B-Frame from referencing the previous P-Frame, and checking the decoding order of the B-frames with respect to the I-frame in the GOP.

I've not written an H.264 parser so I couldn't tell you exactly how the algorithm would work but I'd assume it'd be roughly like that.