Interlace or Progressive ?

Discuss about generic usage of MediaCoder.

Moderator: HuggiL

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

Interlace or Progressive ?

Post by meRobs » Sun Nov 21, 2010 1:23 pm

[Updated 21 Aug 2011]

I. Introduction
Video files are either 'Progressive' or 'Interlaced'. The video content in a Progressive file is fed to a player, frame by frame, with each frame containing all lines of pixels listed sequentially, line 1, line 2, etc. The player then displays each frame ~all at once.

All Software players and most hand-held devices like iPhones, etc, operate in Progressive, which is probably why most conversions by MediaCoder are also in Progressive, by default, a process known as de-interlacing. On clicking the Effects button on the Picture tab of MediaCoder, you can view the setting for this. The default setting is 'Auto', which means that MediaCoder should automatically decide whether the source file is to be de-interlaced (if interlaced) or not (if already progressive)!

On the other hand, Interlaced video has each frame split into two fields, with the Top field having only the odd lines (lines 1, 3, 5, etc) and the Bottom field with the even lines. Hence, PAL has its 25 frames per sec transmitted as 50 fields in each second and, of course, each field has the video data for only half a frame. At this point, it is important to note that the fields must be played in the correct order, in the same order in which they were originally created. If played out of sequence, jitter may well result. Thus, interlaced files are either marked ('flagged') as Top Field First (TFF) or Bottom Field First (BFF), and the order may be checked by dropping the file into Gspot, a freebie.

Virtually all standard DVDs are created with interlaced video frames, which is just a legacy of the analogue TV that needs to be fed with interlaced frames. An analogue TV creates its image by scanning (drawing) its screen from left to right and from top to bottom and is done in two sweeps. First, every second line is 'drawn' and then on the next sweep the alternate lines are displayed, depending on the TFF/BFF flag.

Because of the above, the video material on DVD is stored in VOB files as an MPEG2 stream with Interlaced frames, often as 'Bottom Field First' (BFF), such as from Adobe Encore, but may easily be TFF. Also, the video will have a GOP duration of 12 to 15 frames (see viewtopic.php?f=17&t=8599&start=0).

NOTE 1: a warning: the 'Auto' de-interlacing function should not be relied upon! It works in many builds, such as 4582, but not in 4640 or 4720. Therefore, if you want a Progressive output, it is safer to Enable de-interlacing for an interlaced file (VOB, say) and Disable for a Progressive file, such as an FLV.

II. Methods of Affecting the Interlacing
Whether a transcoded file is to be Progressive or Interlaced will be influenced by:
1. The De-interlace setting, which may be set via the Effects button on the Picture tab or, more conveniently, on a tab opposite the Picture tab. The first opens the Clipping and Effects window where “De-Interlace” may be set to Auto, Enable or Disable and the algorithm for de-interlacing may be set, if used. Since build 5002, the de-interlacing commands were replicated in an Effects tab opposite the Picture tab, which also includes the settings of Field Order. Later, build 5160 saw these options moved from the Effects tab to the “Scale” tab.
2. The Video settings via the Settings button on the Toolbar (third from the right). Prior to build ~4640, go to Video Encoders > FFmpeg, where “Force Interlaced Encoding” (false, by default) and “Force Field Order”. The latter is disabled by default, and may be set to ‘0 field First’ (BFF), ‘1 field first’ (TFF) or ‘Auto’. By build 4640, these commands had been moved to Settings > Overall > Video and re-named to “Interlacing enabled” and “Field Order”. The latter may be changed from Auto to BFF or TFF, but not ‘Disabled’. Note that ‘Settings’ need not be accessed since build 5002, since the changes may be done via the Effects tab (before then, Field Order was not available on Effects).
3. Unless changes are intentionally made to the above, files output from MediaCoder are Progressive, by default.

III. De-interlacing Algorithm
MediaCoder offers 9 choices for the algorithm (computational procedure). They are: Linear Blend, Linear Interpolating, Cubic Interpolating …, YADIF and Motion Compensating. In early builds the default tended to be Linear Blend, whereas, in more recent ones, it is YADIF.

Tests done in build 4640 (viewtopic.php?f=17&t=9488) using VOB source files indicated that Motion Compensating takes 4-5 times longer than the others to de-interlace. And that the best results in that test were for Cubic Interlacing.

I re-checked the conversion times in build 5175 via a dual core CPU with “All Cores” checked on the Tasking tab and using a 100-sec VOB source file converted to MPEG2, as per the settings in the Encoding Guide (viewtopic.php?f=17&t=9643). Note that the Video Encoder was FFmpeg, not CUDA, and the Video Decoder (‘Source’) was MEncoder. During conversion the CPU usage fluctuated a lot and at about halfway through the 100-sec Interlaced file the CPU usage values (Decoder/Encoder) were:
(*) De-interlace = Auto & Algorithm= Linear Blend took 29 sec with CPU usage ~25/45%
(*) De-interlace = Enable & Algorithm= Linear Blend took 29 sec with CPU usage ~25/45%
(*)De-interlace = Enable & Algorithm= YADIF took 29 sec with CPU usage ~45/50%
(*)De-interlace = Enable & Algorithm= Cubic Interl. took 27 sec with CPU usage ~25/50%
(*)De-interlace = Enable & Algorithm= Motion Comp. took 159 sec with CPU usage ~50/8%
(*) De-interlace = Disabled took 41 sec with CPU usage at ~12/50%.

I interpret these values to mean that (1) Auto de-interlacing gives a progressive output by default, using the set Algorithm (in this case, Linear Blend), (2) the Motion Compensation algorithm required more computing power and that it seemed to be done by the decoder with its output rate so low as to need only 8% CPU for the encoding. Also, (3) that with de-interlacing disabled, the decoder has a reduced role and the encoder struggles with the more complex frame information, while being confined to 50% CPU (one core?).

The above VOB file was interlaced with BFF and had a GOP duration of 15 frames. It was NTSC with MPEG2 video at 5984 kbps and AC3 audio in stereo at 224 kbps and 48 kHz. To check the response to the above De-interlacing settings for a Progressive source, I created a Progressive MPEG2 file by converting the VOB with De-interlacing Enabled and the tabs adjusted to give the same bitrates (and file size) as the VOB and with GOP of 15.

When using the same settings as used above for the interlaced VOB on this 100-sec Progressive file:
(*) De-interlace = Disabled took 28 sec with CPU usage at ~22/47%.
(*) De-interlace = Auto & Algorithm= Linear Blend took just as long with the same CPU usage and gave the identical file size.

That ‘Auto’ de-interlacing behaved the same as ‘Disabled’ is as it should be since a Progressive source file neither needs de-interlacing nor should it be de-interlaced. Notice that the conversion of the MPEG2/AC3 file with De-interlace at its default value (Auto) was only marginally quicker (28 sec) when Progressive than Interlaced (the VOB).

IV. Behaviour of MediaCoder
The interlacing functions mentioned above, tended to fail in early builds of MediaCoder. In some builds, such as 4399, 4582 and 4616, the forcing of interlacing for a progressive file was often possible. However, the retaining of interlacing was not.

Progressive source file, such as an FLV, should not be de-interlaced since they are not interlaced. Enabling de-interlacing for a progressive file is likely to cause unwanted artefacts – see: viewtopic.php?f=17&t=9488&p=28837#p28837. This is the basis of the Auto-De-interlacing test in the Test Reports, such as: viewtopic.php?f=17&t=9611

On the other hand, you may de-interlace an interlaced source file (to progressive), such as a VOB, MPEG2 or MKV, or leave it interlaced. Thus, there are four options for an interlaced source file:
(A) De-interlace = Auto, the default. It would usually give a Progressive output (default state)
(B) De-interlace = Enabled should give a Progressive output whether the Field Order = Auto, the default, or otherwise.
(C) De-interlace = Disabled should give an Interlaced output, regardless of the Field Order settings. When the Field Order is set to “Auto’, the output should be interlaced; with the same field order as the source file.
(D) De-interlace = Disabled should give an Interlaced output with the Field Order as set on the Effects tab (BFF or TFF).

However, prior to build 5125, the conversion of an interlaced file gave a progressive output regardless of the settings. The first real attempt to allow interlacing to be retained was in build 5125. So, as a test, I took a VOB with TFF (Top Field First) and tried the three conversions B, C and D to MPEG2 (settings in the Encoding Guide, at viewtopic.php?f=17&t=9643): strangely. Option B, above failed and the other two worked! This was reported in a Bug Report.

Build 5126 claimed to have fixed this bug. It did. However, whereas, Option B worked, Option C now failed – it gave a progressive output! This bug continued in 5130 and was fixed in build 5135.

Thus, as of build 5126, an interlaced file may not only be output as a progressive file, if desired, but its interlacing status may be retained or its field order reversed. As a result, the “Interlacing” test was added to the Test Report (viewtopic.php?f=17&t=10383).
Have you checked out the Tips & Guides for MediaCoder? Try:
Also, get older builds at: