Log in

View Full Version : MediaInfo GOP length mystery


Gregleto
24th October 2013, 19:05
So I’m trying to resolve a mystery related to GOP settings… specifically when it is reported as (M=x, N=x). Every once in a great while, for reasons I’ve NEVER been able to uncover, MediaInfo will report a value in a field called “Format settings, GOP”. It is almost never reported on our files, but recently I noticed an instance where it was reported on one of our files as M=1, N=120. Since I hate seeing aberrations, (especially those I can’t explain :confused:), I decided to dig a little deeper.

Based on my research, I believe that M represents the distance between two anchor frames (I or P)… or when B frames are used, the size of the BP groups. Please correct me if this is wrong.

Since this file is BASELINE profile it won’t have B frames, so M=1 makes perfect sense to me. However, my research indicates that the “N” value represents the GOP size (number of “I” and “P” frames in a GOP)… or in instances where B frames are used, the number of BP groups and I frames per GOP. Again, please correct me if this wrong as well.

If my previous assumptions are correct, here’s the “N” related mystery to me…

Since our Baseline profile file has no “B” frames, 120 seems like an especially long GOP size. In most other instances where I’ve seen these numbers reported (YouTube files and elsewhere), I’ve generally seen much smaller “N” numbers… more like M=1, N=33.

My puzzlement is compounded by the fact that our file has the keyint set at 120, so it seems like too much of a coincidence that our keyint is precisely the same number as MediaInfo is reporting at the GOP size… unless they are equivalent. But we have scenechange set at default (40), and there are definitely scene changes in this video, so that means we must be dropping IDR frames at scene changes.

All of this raises a couple of questions…
1. Does ANYONE understand what makes MediaInfo report the M and N values? There has to be a reason it does it for some files and not others.

2. Am I correct that the “N” value is supposed to represent GOP length?

3. What actually defines the length of a GOP in x264, and what relationship do IDR I frames and non-IDR I frames have on defining GOP length?
Sorry for the longwinded questions, but the seemingly inconsistent reporting of these M and N values have been bugging me for a while.

Thanks,

Gregleto

sneaker_ger
24th October 2013, 19:15
1., 2.:
http://forum.doom9.org/showthread.php?t=167216

3. What actually defines the length of a GOP in x264, and what relationship do IDR I frames and non-IDR I frames have on defining GOP length?

IIRC the H.264 specs do not know the term "GOP" at all, only "coded video sequence". They are defined as IDR frame to frame preceding the following IDR frame.

MasterNobody
24th October 2013, 19:58
MediaInfo is open source project so you can always look in to source code (that is what I did to answer your question) if not sure what some value mean. In the case of AVC you need to read File_Avc::GOP_Detect (http://sourceforge.net/p/mediainfo/code/HEAD/tree/MediaInfoLib/trunk/Source/MediaInfo/Video/File_Avc.cpp#l3631) method.
1. "M=" is constant delta between non-B-frames i.e. B-frames continues sequence length + 1. "N=" is constant delta between I-frames (btw, MediaInfo don't make difference between IDR-frames and I-frames). It doesn't report it on the most x264 encoded files because it usually use adaptive (not constant) number of B-frames and adaptive GOP length (scenecut detection) but MediaInfo report this only when M and N is same for all file GOPs.
2. Mostly if you will ignore the fact about ignoring IDR- vs I-frame difference.
3. GOPs length in x264 is defined by --keyint and scenecut detection algorithm which can make GOP shorter than --keyint. Only IDR-frames (and recovery points) close the GOPs. Simple I-frames don't close the GOP.