Rediger

Del via


To Use Interlaced Video

[The feature associated with this page, Windows Media Format 11 SDK, is a legacy feature. It has been superseded by Source Reader and Sink Writer. Source Reader and Sink Writer have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use Source Reader and Sink Writer instead of Windows Media Format 11 SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

There are two basic types of video encoding: progressive and interlaced. In progressive encoding, each frame is an encoded representation of one frame of video. In interlaced encoding, each frame is an encoded representation of either all of the even rows of pixels in the video, or all of the odd rows. Each interlaced frame is called a field, so there are odd fields and even fields. An interlaced display (like a television) renders the fields one at a time, alternating fields. A progressive display renders frames all at once.

The Windows Media Video 9 Advanced Profile codec provides support for maintaining interlacing in compressed streams.

When to Use Interlaced Video

Encoding interlaced video is useful only when the content is displayed on an interlaced device. Content that is intended to be viewed on a television (through a set-top box or other device) may need to be interlaced. Content that is intended to be viewed exclusively on a computer display should not be encoded as interlaced.

To encode interlaced video as progressive video, you must configure input settings. For more information, see To Deinterlace Video.

Field Order

Most sources of interlaced video, such as video capture cards, deliver video samples that include both fields interleaved with each other. The result is like a complete frame of video, except that the odd and even lines are shifted slightly in time. There is no universal standard as to which field in the interleaved video sample occurs first in time.

You should enable users to specify field order when passing interlaced samples to your application.

Encoding Interlaced Video

To use interlaced encoding, perform the following steps:

  1. Configure the video stream in the profile to use the content type data unit extension by calling the IWMStreamConfig2::AddDataUnitExtension method. The sample extension GUID for the content type extension is WM_SampleExtensionsGUID_ContentType.
  2. Set the stream in the profile and configure the writer with the profile as normal.
  3. Before passing interlaced samples to the writer, call the IWMWriterAdvanced2::SetInputSetting method to set the g_wszInterlacedCoding input setting to TRUE.
  4. For every interlaced sample that you pass to the writer, call the INSSBuffer3::SetProperty method to set the content type. Content type values are combinations of the flags in the following table.
Flag Description
WM_CT_INTERLACED Always set this flag when encoding interlaced content. If you use this flag without setting a field-order flag (WM_CT_BOTTOM_FIELD_FIRST or WM_CT_TOP_FIELD_FIRST) the codec will assume that the top field is first. If the codec uses the wrong field order, there should be no impact on image quality, but the encoding efficiency will be affected.
WM_CT_BOTTOM_FIELD_FIRST When combined with the WM_CT_INTERLACED flag, this flag indicates that the bottom field (the field starting with the second line in the sample) occurs first in time.
WM_CT_TOP_FIELD_FIRST When combined with the WM_CT_INTERLACED flag, this flag indicates that the top field (the field starting with the first line in the sample) occurs first in time.
WM_CT_REPEAT_FIRST_FIELD Indicates that the first field in the sample should be repeated on playback. This flag is used for video that has created from film by the telecine process.If no field-order flag is set in conjunction with this flag, the top field is assumed to occur first in time.

Note

If the WM_CT_INTERLACED flag is not set, the sample is assumed to contain a progressive video frame.

Decoding Interlaced Video

When decoding interlaced video, you must set the g_wszAllowInterlacedOutput setting to TRUE using the IWMReaderAdvanced2::SetOutputSetting method. Otherwise the codec will deliver progressive frames.

The content type data unit extension is maintained on the output samples. You should pass the field orientation to the rendering device to ensure proper playback.

Advanced Topics