I have a h264 file that extract from YUV format using SVC software. Now, I want to caculate size of each GOP in the h264 file. We know that size of GOP is the distance between two nearest I frame. here. Could you suggest to me how to cacluate the GOP size of a given h264 file. It is better when we implement it by C/C++.Thank you
Simply put, a GOP is the distance between two keyframes, measured in the number of frames, or the amount of time between keyframes. For example, if a keyframe is inserted every 1 second into a video at 30 frames per second, the GOP length is 30 frames, or 1 second.
Recommendation: When using MPEG-2, the recommended GOP size is up to 30. A size of 15 is also common. For H. 264, the recommendation is to make the GOP size as large as possible while still meeting other encoding requirements.
In video coding, a group of pictures, or GOP structure, specifies the order in which intra- and inter-frames are arranged. The GOP is a collection of successive pictures within a coded video stream. Each coded video stream consists of successive GOPs, from which the visible frames are generated.
(long Group Of Pictures compression) The interframe coding of digital video in which a full video frame (the "keyframe") is followed by a number of delta frames ("difference frames") until the next keyframe is reached. See interframe coding.
Well, just parsing the bitstream to find the each I-frame is a bit tricky; among other things the encode order might be (or not) different from the display-order. One solution is to use http://www.ffmpeg.org/ffprobe.html from the ffmpeg-suite.
Example:
ffprobe -show_frames input.bin | grep key_frame
key_frame=1
key_frame=0
key_frame=0
key_frame=0
key_frame=0
key_frame=0
...
from the output you can easily calculate the GOP-length
Another solution is to patch the reference implementation found at http://iphome.hhi.de/suehring/tml/
Let me know if you need help with this part :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With