GOP:
The video quality and compression ratio depends on Group of Pictures (GOP) structure. GOP structure also affects the distortion sensitivity of the video stream due to packet losses.
Increasing the GOP length, also increases the video quality. But after reaching the highest PSNR (Peak Signal to Noise Ratio), it starts to decrease. In the first increasing period, the efficient coding plays major role, so higher of GOP lengths lead to a better quality. After the optimal of GOP settings, when the video quality is the highest, the error propagation effect becomes more significant. Hence, using higher Intra frame (I-frame or Key frame) intervals, the error will be spreading because of significant distortion.Source
Each type of video has different optimal GOP, depend on its characteristic.
Key Frame and Animation:
Videos or moving images - we're just tricking our minds; they're just still images displayed at a rapid succession! And the illusion gets better and smoother if the next frame appears at/before 1/25
th of a second which is the Human eye afterimage persistance time interval and the reason for motion perception.
Illustration 1: (source: Wikipedia)
Fig: A sequence of video frames, consisting of two keyframes (I), one forward-predicted frame (P) and one bi-directionally predicted frame (B).
(You may note that, in the above image the value of GOP, -g
is 3, one key-frame with two supplimentary frames.)
Illustration 2: (source: Wikipedia)
Fig: A very simple animation created by key-framing. The animation lacks smoothness because each frame is completely independent of any other frame.
A possible Q&A:
Q. Aren't key frames enough? Why would we need to have the supplimentary/intermediate P-frames, B-frames?
A. Yes... but the use of such intermediate frames allow to reduce the overall size of the file (video).
For better quality video/streaming, you'd look to use low compression ratio but high frame rate which means high -g
value with avconv
(optimum GOP value is nearly half the value of frames/sec). As evident, the value for -g
will have to be specified based on the coders, compression ratio, frame rates that you're using for the transcoding/streaming purpose; it's a relative quantity so there's no general value you can use with all inputs.
According to this link the value of GOP for most media would be about half the value of frame rate so that the key frame would be about 0.5
seconds apart and would produce a good quality video. We may also note that other link shows the PSNR attains a constant value at around half the test frame rate as indicated in the graph plot.
But the optimal value seems to lie around 1/6
th to 1/4
th the test frame rate.
And yeah, so you should be looking to use -g
value around or in the range 1/6
th to 1/4
th so that the key frames appear every 0.17
to 0.25
seconds; and probably comment to improve the answer :)
References: