Set I-frame interval (GOP) for your MPEG2 files

Discuss about generic usage of MediaCoder.

Moderator: HuggiL

Locked
meRobs
Expert
Expert
Posts: 3116
Joined: Tue Jun 23, 2009 2:45 pm
Location: Sydney, Australia

Set I-frame interval (GOP) for your MPEG2 files

Post by meRobs » Thu Feb 25, 2010 3:25 pm

[updated 19 Apr 2011]

To fully satisfy DVD-compliance, MPEG2 files need a suitable GOP structure. GOP stands for 'Group of Pictures' and refers to the sequence of frames in the MPEG2 file, which on a DVD adopts the .VOB extension. When a MPEG file is created, the compression algorithm puts the video content into different types of frame, usually just I-frames, P-frames and B-frames. The I-frames are almost complete and can be played without any further information. They may be compressed, in a similar manner to that used for JPEG compression, but they don't rely on other frames for their interpretation or playing. On the other hand, P-frames contain only the details that describe the differences between that frame and the previous frame – they are forward 'Predicted'. A B-frame ('Bi-predictive picture'), on the other hand, contains only the differences between the current frame and both the preceding and following frames and, as a result, allows more compression.

A GOP consists of an initial I-frame and a sequence of P and B frames. The GOP length is the number of frames in each repeated sequence (one I-frame in each). The max GOP length allowed by the DVD Specs is 18 for NTSC and 15 for PAL. MediaCoder, by default, creates MPEG2 files with a GOP of 250 frames, when using the FFmpeg encoder, ~0.5% being I-frames with the rest as P-frames.

MPEG2 files created in MediaCoder (build 4788) using the FFmpeg encoder are seen in Gspot as having ~100% P-frames with only the occasional I-frame. When placed on DVD, via an authoring App that doesn't re-encode, such as DVDstyler (see: viewtopic.php?f=17&t=8454&start=0), standalone players have difficulties with its play, often freezing and/or stopping altogether.

Setting the GOP in MediaCoder: the only way I know of getting DVD-compliant files with the 'correct' GOP structure is to use the FFmpeg encoder. Since build ~5120, this was easy. When FFmpeg is selected on the video tab, the FFmpeg tab at right displays the setting for GOP, as 250 by default. In earlier builds, it may be set via the Advanced Settings button on the Toolbar (spanner icon, third from the right). Then, select Video Encoders > FFmpeg > “Maximum interval between Keyframes, in frames” or simply click on the “Encoder” button on the video tab.

One combination of parameters that gives DVD compliance is that given for MPEG2 in the Encoder Guide: viewtopic.php?f=17&t=9643. I suggest you begin with 'Revert all Settings' or, better still, use the 'Starter Preset' described in viewtopic.php?f=17&t=8131. Then, set the above and fiddle to your satisfaction and save as a Preset.

NOTE: the use of AviSynth A suitable GOP may also be set when using AviSynth as the Video source and FFmpeg as the encoder. One advantage of using AviSynth instead of MEncoder as the source is that it makes use of any Video Delay value in the source metadata and, thus, gives in-sync audio when converting MPEG or VOB source files. This doesn't matter if the advice in viewtopic.php?f=17&t=8082&start=0 is followed.

Another possible advantage is in the GOP structure. For a GOP length of 12, both AviSynth and MEncoder give 8% I-frames. However, with MEncoder the other 92% are all P-frames, yet, with AviSynth half of these are P and the others are B-frames. The latter type allows more compression.

The disadvantage in using AviSynth as video Source is that the conversion takes almost twice as long. It also seems to give a slight pinkish cast when compared to MEncoder as the video source.
By the way, it takes even longer if AviSynth as source is combined with MEncoder as the encoder (also, cannot then set the GOP)!
See also: viewtopic.php?f=17&t=8624&start=0
Have you checked out the Tips & Guides for MediaCoder? Try: http://forum.mediacoderhq.com/viewtopic.php?f=17&t=8061
Also, get older builds at: http://www.videohelp.com/tools/MediaCoder/old-versions#download

Locked