Checking Interlacing Flags

With the replacement of conventional televisions by progressive scan LCD and gas plasma displays it is surprising that today's high definition camcorders still record interlaced video. It seems plausible that interlaced video will be common in consumer camcorders at least until the year 2015. This document discusses how to verify that the flags are set correctly in an interlaced video file.

Each frame from an interlaced source consists of two fields, a top field and the bottom field. Exactly how these fields are stored depends on the video encoding used. When the top field is displayed it fills every other horizontal scan line starting with the top most line in the image. When the bottom field is displayed it fills every other horizontal scan line starting with the scan line second from the top.

Before burning a file to a SVCD, DVD or Blu-ray disk it is important to check that the interlacing order is correct because if the order is not correct, the video will not play smoothly.

Required Software

Checking Interlace Order

If you play interlaced video on a computer monitor without additional post processing then interlacing will appears as a combing effect on fast moving objects. The combing results because the even and the odd lines of the image which were recorded at different points in time are being displayed at the same time.

When you see this combing effect you have interlaced or telecined video. In either case, the first thing to do is determine the field order. To do this play the video with

$ mplayer -vf tfields=1:0 video.mpg
If the motion looks smooth then the field dominance is top field first; if the motion is not smooth it is bottom field first. To verify the field order play the video again with
$ mplayer -vf tfields=1:1 video.mpg
If the motion did not play smoothly before then it should look smooth now; if it was smooth before then it should no longer be smooth.

A related way to check the interlacing order of the video is with ffmpeg and mjpegtools using the method given in When to Deinterlace a Video. Convert your clip to progressive video with a 59.96 frame rate in two different ways: once as if it were interlaced bottom field first and again as if it were interlaced top field first. Play back each progresive video file. The file that plays smoothly is the one that was deinterlaced with the correct interlacing order.

Detecting Telecined Video

Play the video frame by frame and look for a pattern of two interlaced frames followed by three progressive frames. If your video has this pattern it is telecined. Telecined video comes from the 24p mode in some camcorders and from transferring film source to video. The interlacing flags for telecined video can be verified in the same way as interlaced video. More information about telecined video can be found in PF24 Pulldown Removal with Linux.

Verifying the Interlacing Flags

Verify that the flags embedded in the video stream accurately reflect the interlacing order with
$ mediainfo video.mpg
The output should contain lines like
Scan type                        : Interlaced
Scan order                       : Bottom Field First
Check that the interlacing order it correct. Note that if the video format is Digital Video then the scan order is not reported but should be assumed to be bottom field first.

Fixing the Interlace Order

If the interlacing determined by examining the video with mplayer does not agree with the interlacing order given by the flags then the video will not play smoothly from an SVCD, DVD or Blu-ray disk. Fix the encoding step in the workflow so the flags are correct. The interlace options patch for ffmpeg given on the page DVD Compliant mpeg2 on Linux may help.

Reencode the video only as a last resort. The program restream can be used to change the interlacing flags in a elementary mpeg2 video stream on Windows or Wine. For Linux I have created a modified version of dgpulldown which can also be used to change the interlacing flags in an elementary mpeg2 video stream. Using this modified version of dgpulldown, one can flag an interlaced m2v file as top field first with the command

    dgpulldown input.m2v -interlaced -o output.m2v
Similarly, one can flag an interlaced m2v file as bottom field first with the command
    dgpulldown input.m2v -interlaced -bff -o output.m2v
Comments on the modification can be sent to video@renomath.org. Much thanks goes to Donald Graft who wrote the Windows code for dgpulldown and released it under the GNU GPL.

Conclusions

The method outlined here should prevent making disks with interlaced video that has the field dominance improperly flagged. Proof that the workflow is correct is a test disk. Find a short video clip containing a fast camera pan across a scene. Check the workflow by encoding the clip as if it were interlaced top field first and again as if it were interlaced bottom field first. Play the disk in a player connected to a standard definition television with a interlaced cathode ray tube display. Do not use a progressive scan player or a high definition television. The video file which shows smooth motion is the one that corresponds to the workflow with the correct interlacing order.

Note the hrd_pd_interlace patch is needed for x264 to include interlacing flags in the encoded h264 video stream. The Toshiba A2 will randomly choose an interlacing order if the video stream is not properly flagged. More information on encoding interlaced h264 video is given at H264 HD Video Workflow.


Last Updated: Sun Jun 5 18:27:55 PDT 2011