LEADTOOLS Filters Help > Filters, Codecs and Interfaces > Video Codecs > MPEG-2 > ILMMPEG2Encoder Interface |
The portion of the file holding the video data. The video data might be compressed to save disk space. The data has to be decompressed using a video decompressor before you can play (see) it.
Also known as compressor, this is a module or algorithm to compress data. Playing that data back requires a decompressor, or decoder.
Also known as compressor, this is a module or algorithm to compress data. Playing that data back requires a decompressor, or decoder.
When "getting" a BSTR property, the memory containing the string is allocated with SysAllocString. When this string is no longer needed, free this memory by calling SysFreeString if you are working in an environment such as C or C++ that does not automatically delete the memory. VB automatically deletes the memory, so VB programmers do not need to free the memory themselves.
This is the interface for the LEAD MPEG-2 Encoder .
Interface Properties:
Type |
Name |
Description |
MpegVideoType |
This option offers encoding parameters for VCD, SVCD, DVD and DICOM (if you select these, you cannot change most other options). If you choose MPEG1 or MPEG2, you can create a custom video stream by changing other options described below. Possible values are: MPEG2Type_MPEG1 = 0, The encoder is capable of generating MPEG-1 or MPEG-2 video.
|
|
PlaybackFramerate |
This option sets the playback frame rates of the compressed video no matter what the input stream rate is. LEAD MPEG-2 Encoder will automatically adjust the input video to match the desired frame rate. The adjustment is done through dropping or duplicating input frames. Possible values are: FRAMERATE_23_98 = 0,
|
|
MPEG2Profile |
Use this option to Set MPEG2 profile *. Possible values are: MPEG2Profile_Simple = 0, Default value is MPEG2Profile_Main. All MPEG2 Profiles listed above are generated using the 4:2:0 Chroma Format. The LEADTOOLS MPEG2 Encoder MPEG2Profile_High does not support the 4:2:2 Chroma format. |
|
MPEG2Level |
Use this option to set MPEG2 level *. Possible values are: MPEG2Level_Low = 1, Default value is MPEG2Level_Main
|
|
RateControlMethod |
Three control methods can be selected with this property: MPEG2_CONSTANT_BITRATE (Fixed output rate): If this is selected, the compression level is constant and the storage requirements are easily predicted. This may affect the video quality of more dynamic scenes and pictures with lots of detail. The bit rate describes the amount of data used or transferred per second. It is directly related to the compression level. For example, a DV video (approximately 1:5 compression) would need 25 Mbit (3.12MB) per second. Using MPEG-2 compression at bit rate = 6 Mbit/sec, the compression level will be 1:27. Therefore, the higher the bit rate, the lower the compression and the better the quality. The bit rate can be adjusted using the Bitrate edit box. For both Variable Bitrate and Fixed Bitrate, the video quality also depends on the MPEG-2 profile used (4:2:2 or 4:2:0) and the distance between I frames and P frames. MPEG2_CONSTANT_QUALITY (Variable bit rate and Fixed video quality). If this selected the compression rate varies with scene content. For more dynamic scenes a high bit rate (low compression) is used to maintain consistent video quality. Setting a quality value in the Quality drop down box can further control the quality. MPEG2_VARIABLE_BITRATE If this is selected, the compression rate varies with scene content. The MinQuantizerValue, MaxQuantizerValue, Bitrate will control the video quality. The video quality will vary between the Minimum and Maximum quality factors, and the rate will not exceed the Maximum Bitrate. This option should be used when good video quality is required at a certain bit rate. (A common use for this is DVD creation). You achieve the best compression-quality performance when you use this option. For this option, the compressor increases or decreases the quality factor automatically to maintain the highest quality at the desired bit rate, specified in the Average Bitrate and the Maximum Bitrate edit boxes. However, the quality factor will not go below the Minimum Quality factor or exceed the Maximum Quality factor. MinQuantizerValue and MaxQuantizerValue properties indicate the range allowed for the quantizer. MinQuantizerValue must be less than MaxQuantizerValue. The quantizer is directly proportional with the compression ratio and inversely proportional with the quality. (A high quantizer value will generate a low size for the compressed stream but at a lower video quality). To give the compressor the whole range of possible compression, you can set MinQuantizerValue to 1 and MaxQuantizerValue to 31. But if you want to restrict it from generating video of bad quality, you can set MaxQuantizerValue to the highest quantizer you consider acceptable. For example, if you decide video generated with quantizers 20 and above generate video of unacceptable quality, you can set MaxQuantizerValue to 19 and you are guaranteed to generate video with quantizers of 19 or less. Therefore, high quantizer = high compression = small compressed video files = poor video quality. Low quantizer = low compression = large compressed video files = high quality. |
|
Options |
Possible values for the encoder are as follows: MPEG2EncoderFlag_None MPEG2EncoderFlag_DisableMediaTypeLMP2 The default value is MPEG2EncoderFlag_None. If the eMPEG2EncoderFlag property is set to MPEG2EncoderFlag_DisableMediaTypeLMP2, the encoder will not offer the MEDIASUBTYPE_LMPG2 subtype. Only the MEDIASUBTYPE_MPEG2_VIDEO subtype will be offered. This is useful when using generic container formats like OGG that accept any media type. For example, if a conversion is performed with MPEG2EncoderFlag_DisableMediaTypeLMP2 set and OGG is used as an output format, then the MPEG2 stream will be saved using the MEDIASUBTYPE_MPEG2_VIDEO subtype. The MEDIASUBTYPE_MPEG2_VIDEO subtype can be moved to MPEG2 Program / Transport easily without video recompression. If the eMPEG2EncoderFlag property is set to MPEG2EncoderFlag_None, the encoder will offer both media subtypes (MEDIASUBTYPE_MPEG2_VIDEO and MEDIASUBTYPE_LMPG2). |
|
long |
QuantizerValue |
This option is active only when RateControlMethod equal to MPEG2_CONSTANT_QUALITY Use this option to set the video quality. A QuantizerValue of 1 gives the best quality and the biggest video size, while a QuantizerValue of 31 gives the smallest file size with low video quality. A QuantizerValue of 4 has been chosen as the default value. |
long |
MinQuantizerValue
|
This option is active only when RateControlMethod equal to MPEG2_VARIABLE_BITRATE. For variable bitrates, the encoder will not use a quantizer below this value. This value range is 1 - 31. |
long |
MaxQuantizerValue |
This option is active only when RateControlMethod equal to MPEG2_VARIABLE_BITRATE. For variable bitrates, the encoder will not use a quantizer above this value. This value range is 1 - 31. |
long |
Bitrate |
Set the bitrate for mpeg2 encoder in bits per second units. use this when RateControlMethod is set to MPEG2_CONSTANT_BITRATE or MPEG2_VARIABLE_BITRATE. For MPEG2_VARIABLE_BITRATE this value will represent the average bitrate. |
long |
I_FrameDistance |
This option set the distance between I frames or how many frames between each I frames. Note that all frames between I frames are P or B frames ***. It is preferable to update P_FrameDistance before I_FrameDistance since updating one might change the other. Also notice that I_FrameDistance always should be multiple of P_FrameDistance .
|
long |
P_FrameDistance |
This option set the distance between P frames or how many frames between each P frames. Note that all frames between P frames are B frames ***. It is preferable to update P_FrameDistance before I_FrameDistance since updating one might change the other. Also notice that I_FrameDistance always should be multiple of P_FrameDistance .
|
VARIANT_BOOL |
ShowWarningMessage |
This property is now obsolete. It is now ignored by the encoder and will be removed in future versions of the encoder.
|
VideoFormat |
Specifies the TV system on which the MPEG file will be played (NTCS, PAL). Use this property when producing a file to be played on TV, such as a DVD or VCD. For information about HDTV resolution, please see http://en.wikipedia.org/wiki/high-definition_television. Also see "Supplement 137: MPEG2 MP@HL Transfer Syntax" of the DICOM specification for more information on the restrictions for the HDTV video that can be stored inside DICOM files.
|
|
AspectRatio |
Sets the desired aspect ratio during playback. The video will be adjusted if it does not match this desired aspect ratio, unless the IgnoreInputAspectRatio property is set to VARIANT_TRUE.
|
|
DisplayScan |
This option should be set to -Interlaced- if the mpeg2 file needs to be played on an interlaced device, like a TV set. Otherwise set this option to "Progressive" if the mpeg2 file needs to be played on a progressive display device like a Computer Monitor.
|
|
VARIANT_BOOL |
IgnoreInputAspectRatio |
If VARIANT_TRUE: the input aspect ratio is assumed to be the same as the output aspect ratio. In this case, the encoder will not add black bars and the output video might be distorted. If VARIANT_FALSE: the input aspect ratio is assumed to be correct and the encoder will preserve the input aspect ratio when resizing or adjusting the video. Black horizontal or vertical bars might be added if the input aspect ratio does not match the output aspect ratio. |
DefaultMpegMode |
This option set the default MPEG2 encoding mode, which decides the MpegVideoType to be applied by default when preparing the MPEG2 encoding options. |
|
EncodingThreads |
The number of threads used during encoding. The maximum number of threads that can be used is 4. Possible values are: MPEG2_THREAD_AUTO: the encoder will pick the best number of threads for your computer. MPEG2_THREAD_1 MPEG2_THREAD_2 MPEG2_THREAD_3 MPEG2_THREAD_4 If 'X' Encoding thread(s) : the encoder will use 'X' encoding threads, where x is from 1 to 4. This property allows you to tweak the speed of the compression depending on the number of processors in your system. Encoding is faster on multiprocessor computers if more than one thread is used. |
|
VARIANT_BOOL |
PictureCodingType |
If VARIANT_TRUE the Field coding will be used: the even rows are encoded as one field and the odd rows are encoded as another field. This option can increase compression for interlaced videos. If VARIANT_FALSE the Frame coding will be used: each video frame is encoded one frame (both even and odd rows are encoded together). |
unsigned long |
EstimatedBitrate |
(Read-only). Use this property to obtain the estimated bitrate (bit per second). |
TimeQualityFactorFileName |
Set the Time / Quality factor file name, when this option used, the MPEG2 Encoder will set the quality according to Time/Quality records provided in the file. |
Parameters
ApiLevel
Description
Resets encoder to default values. The ApiLevel determines which default values to use. Current applications should set ApiLevel to MPEG2_APILEVEL_2 = 1.
The encoder might change in the future and have different properties or default behaviour. Calling this method ensure the filter will have the same default values as they were at the time you developed your application.
It is recommended you call ResetToDefaultsEx(MPEG2_APILEVEL_2) before you start setting properties for this interface.
Returns
S_OK
typedef enum { MPEG2Type_MPEG1 = 0, MPEG2Type_VCD = 1, MPEG2Type_MPEG2 = 2, MPEG2Type_SVCD = 3, MPEG2Type_DVD = 4 } eMPEG2VIDEOTYPE;
typedef enum { FRAMERATE_23_98 = 0, FRAMERATE_24_00 = 1, FRAMERATE_25_00 = 2, FRAMERATE_29_97 = 3, FRAMERATE_30_00 = 4, FRAMERATE_50_00 = 5, FRAMERATE_59_94 = 6, FRAMERATE_60_00 = 7 } eMPEG2FRAMERATE;
typedef enum { MPEG2Profile_Simple = 0, MPEG2Profile_Main = 1, MPEG2Profile_High = 2 } eMPEG2PROFILE;
typedef enum { MPEG2Level_Low = 1, MPEG2Level_Main = 2, MPEG2Level_High1440 = 3, MPEG2Level_High = 4 } eMPEG2LEVEL;
typedef enum { MPEG2MODE_GENERAL = 1, MPEG2MODE_DVD = 2, MPEG2MODE_DICOM = 3, MPEG2MODE_MPEG1 = 4, MPEG2MODE_VCD = 5, MPEG2MODE_MPEG2 = 6, MPEG2MODE_SVCD = 7 } eMPEG2DEFAULTMODE;
typedef enum { MPEG2_DS_PROGRESSIVE = 0, MPEG2_DS_INTERLACED = 1 } eMPEG2DISPLAYSCAN;
typedef enum
{ MPEG2_VF_PAL = 1, MPEG2_VF_NTSC = 2, MPEG2_VF_HDTV_720 = 3, MPEG2_VF_HDTV_1080 = 4 } eMPEG2VIDEOFORMAT;
typedef enum { MPEG2_VARIABLE_BITRATE, MPEG2_CONSTANT_QUALITY, MPEG2_CONSTANT_BITRATE, } eRATECONTROL;
typedef enum { MPEG2EncoderFlag_None = 0, MPEG2EncoderFlag_DisableMediaTypeLMP2 = 0x00000001, } eMPEG2EncoderFlag;
typedef enum { MPEG1_AR_1_0000, MPEG1_AR_0_6735, MPEG1_AR_0_7031, MPEG1_AR_0_7615, MPEG1_AR_0_8055, MPEG1_AR_0_8437, MPEG1_AR_0_8935, MPEG1_AR_0_9375, MPEG1_AR_0_9815, MPEG1_AR_1_0255, MPEG1_AR_1_0695, MPEG1_AR_1_1250, MPEG1_AR_1_1575, MPEG1_AR_1_2015, MPEG2_AR_1_0000, MPEG2_AR_4_3, MPEG2_AR_16_9, MPEG2_AR_2_21_1 } eMPEGASPECTRATIO;
typedef enum { MPEG2_APILEVEL_1 = 0, MPEG2_APILEVEL_2 = 1 } eMpeg2ApiLevel;
typedef enum { MPEG2_THREAD_AUTO = 0, MPEG2_THREAD_1 = 1,
MPEG2_THREAD_2 = 2,
MPEG2_THREAD_3 = 3,
MPEG2_THREAD_4 = 4 } eMpeg2EncodingThreads;