MPEG_OPEN

Syntax | Return Value | Arguments | Keywords | Examples | Version History | See Also

The MPEG_OPEN function initializes an IDLgrMPEG object for MPEG encoding and returns the object reference. The MPEG routines provide a wrapper around the IDL Object Graphics IDLgrMPEG object, eliminating the need to use the Object Graphics interface to create MPEG files.

Note
The MPEG standard does not allow movies with odd numbers of pixels to be created.

This routine is written in the IDL language. Its source code can be found in the file mpeg_open.pro in the lib subdirectory of the IDL distribution.

Note
MPEG support in IDL requires a special license. For more information, contact your ITT Visual Information Solutions sales representative or technical support.

Note
The IDLffMJPEG2000 object creates and reads Motion JPEG2000 (MJ2) files, and provides more functionality than the MPEG_* routines. Animations can consist of monochrome, RGB or multi-component frames that display individual components, tiles or regions. See Overview of Motion JPEG2000 (Using IDL) for more information.

Syntax

mpegID = MPEG_OPEN( Dimensions [, BITRATE=value] [, FILENAME=string] [, IFRAME_GAP=integer value] [, MOTION_VEC_LENGTH={1 | 2 | 3}] [, QUALITY=value{0 to 100}] )

Return Value

Returns the reference to the IDLgrMPEG object.

Arguments

Dimensions

A two-element vector of the form [xsize, ysize] indicating the dimensions of the images to be used as frames in the MPEG movie file. All images in the MPEG file must have the same dimensions.

Note
When creating MPEG files, you must be aware of the capabilities of the MPEG decoder you will be using to view it. Some decoders only support a limited set of sampling and bitrate parameters to normalize computational complexity, buffer size, and memory bandwidth.

Keywords

BITRATE

Set this keyword to a double-precision value to specify the MPEG movie bit rate. Higher bit rates will create higher quality MPEGs but will increase file size. The following table describes the valid values:

Table 15-17: BITRATE Value Range

MPEG Version
Range

MPEG 1

0.1 to 104857200.0

MPEG 2

0.1 to 429496729200.0

If you do not set this keyword, IDL computes the BITRATE value based upon the value you have specified for the QUALITY keyword.

Note
Only use the BITRATE keyword if changing the QUALITY keyword value does not produce the desired results. It is highly recommended to set the BITRATE to at least several times the frame rate to avoid unusable MPEG files or file generation errors.

FILENAME

Set this keyword equal to a string representing the name of the file in which the encoded MPEG sequence is to be saved. The default file name is idl.mpg.

IFRAME_GAP

Set this keyword to a positive integer value that specifies the number of frames between I frames to be created in the MPEG file. I frames are full-quality image frames that may have a number of predicted or interpolated frames between them.

If you do not specify this keyword, IDL computes the IFRAME_GAP value based upon the value you have specified for the QUALITY keyword.

Note
Only use the IFRAME_GAP keyword if changing the QUALITY keyword value does not produce the desired results.

MOTION_VEC_LENGTH

Set this keyword to an integer value specifying the length of the motion vectors to be used to generate predictive frames. Valid values include:

If you do not set this keyword, IDL computes the MOTION_VEC_LENGTH value based upon the value you have specified for the QUALITY keyword.

Note
Only use the MOTION_VEC_LENGTH keyword if changing the QUALITY value does not produce the desired results.

QUALITY

Set this keyword to an integer value between 0 (low quality) and 100 (high quality) inclusive to specify the quality at which the MPEG stream is to be stored. Higher quality values result in lower rates of time compression and less motion prediction which provide higher quality MPEGs but with substantially larger file size. Lower quality factors may result in longer MPEG generation times. The default is 50.

Note
Since MPEG uses JPEG (lossy) compression, the original picture quality can't be reproduced even when setting QUALITY to its highest setting.

Examples

The following sequence of IDL commands illustrates the steps needed to create an MPEG movie file from a series of image arrays named image0, image1, .., imageN, where n is the zero-based index of the last image in the movie:

; Define the dimensions of the images: 
dimensions = [640,480] 
 
; Open an MPEG sequence: 
mpegID = MPEG_OPEN(dimensions) 
 
; Add the first frame: 
MPEG_PUT, mpegID, IMAGE=image0, FRAME=0 
MPEG_PUT, mpegID, IMAGE=image1, FRAME=1 
 
; Subsequent frames: 
... 
 
; Last frame: 
MPEG_PUT, mpegID, IMAGE=imagen, FRAME=n 
 
; Save the MPEG sequence in the file myMovie.mpg: 
MPEG_SAVE, mpegID, FILENAME='myMovie.mpg' 
 
; Close the MPEG sequence: 
MPEG_CLOSE, mpegID 

Version History

5.1

Introduced

See Also

MPEG_CLOSE, MPEG_PUT, MPEG_SAVE, XINTERANIMATE