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

tim nicholson nichot20 at yahoo.com
Fri Jan 9 12:56:55 CET 2015


On 09/01/15 10:06, Valentin NOEL wrote:
> 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 ?
>

Consider the last GOP of the file, you cannot end on a B frame as there
is no forward frame to interpolate from.

I wonder therefore if you need to add " -flags +cgop "


> Thanks.
> 
> Valentin
> [..]


-- 
Tim.
Key Fingerprint 38CF DB09 3ED0 F607 8B67 6CED 0C0B FC44 8B0B FC83


More information about the ffmpeg-user mailing list