[FFmpeg-user] ffmpeg & MPEG-2 GOP structure

Valentin NOEL valent.noel at gmail.com
Fri Jan 9 11:06:13 CET 2015


Hi to all,

I would like to encode MPEG-2 video with closed GOP of 12 frames, and a
structure like IBBPBBPBBPBB.

For doing this, I am using these options :
*-g 12* to set the GOP size
*-bf 2* to set the max B frames between reference frames
*-flags +cgop* to use Closed GOP
*-sc_threshold 1000000000* to disable scene change detection
*-b_strategy  0 *to disable adaptive number of B-frames
*-mpv_flags +strict_gop* to enforce GOP size (mpegvideo private flag)

The resulting command is :
ffmpeg -i input.mxf -vcodec mpeg2video -g 12 -bf 2 -flags +cgop -b_strategy
0 -mpv_flags +strict_gop -sc_threshold 1000000000 -map 0:0 -y output.mxf

However, the result is a GOP of 12 frames IBBPBBPBBPB*P*, with an ending
P-frame.

It seems the problem comes from these lines :
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/mpegvideo_enc.c#L1491

How can I do to fix this ? Is there a way to enforce GOP finishing by a
B-frame ? Is there something missing ?

Thanks.

Valentin


More information about the ffmpeg-user mailing list