Creating MPEGs with IDL 5.3
IDL provides an IDLgrMPEG class that allows the user to save an array of image frames as an MPEG movie. See page 1824 of the IDL Reference guide.
The MPEG_PUT procedure stores the specified image array at a specified frame index in an MPEG sequence. See page 802 of the IDL Reference guide. The MPEG_SAVE procedure encodes and saves an open MPEG sequence. The images can be read using the READ_IMAGE function. See page 981 of the IDL reference guide for details.
Two examples of IDL modules to produce movies are given below. Example1 is a command line MPEG generator and Example2 provides a user interface for the parameters.
Example1 - Command line MPEG generator
make_mpg, synopsis
This module, mpg.pro reads a sequence of images (named prefix00001.suffix) and produces an MPEG1 or MPEG2 movie. Supported formats are: BMP, GIF, JPEG, PNG, PPM, SRF, TIFF, DICOM.
Parameters
| prefix | string(required) | A string specifying the prefix of the images to read included the path, for example "/home/data/images/Image" |
| suffix | string(required) | A string specifying the suffix of the images to read, for example "jpg" |
| n_start | integer(required) | An integer specifying the first image in the sequence |
| n_end | integer(required) | An integer specifying the last image in the sequence |
| digits | integer(required) | An integer specifying the number of digits of the number field in the sequence, for example image00001.jpg would require digits=5 |
| dims | integer(optional) | An integer array specifying the size of the output image. If not specified the size of the first image is used. |
| format | integer(optional) | An integer with values 0 for MPEG1 and 1 for MPEG2. Default is MPEG1 |
| frame_rate | integer(optional) | An integer with values |
| 1 = 23.976 frames/sec: NTSC encapsulated film rate | ||
| 2 = 24 frames/sec: standard film rate | ||
| 3 = 25 frames/sec: PAL video frame rate | ||
| 4 = 29.97 frames/sec: NTSC video frame rate | ||
| 5 = 30 frames/sec: NTSC drop frame video rate (the default) | ||
| 6 = 50 frames/sec: double frame rate/progressive PAL | ||
| 7 = 59.94 frames/sec: double frame rate NTSC | ||
| 8 = 60 frames/sec: double frame rate NTSC | ||
| mpeg_file | string(optional) | A string specifying the output MPEG file (default outfile.mpg) |
| tmp_dir | string(optional) | A string specifying temporary directory to use for the temporary image files |
To run the IDL movie generator type in a shell:
%module load idl %idl > .compile mpg.pro >make_mpg, prefix='image', suffix='.bmp', n_start=0, n_end=100, digits=5, dims=[512,512], mpeg_file='mympeg.mpg'
Example2 - MPEG generator with a GUI
xmpeg, synopsis
This IDL project, mpg_gen.tar.gz reads a sequence of images (named prefix00001.suffix) and produces an MPEG1 or MPEG2 movie. Supported formats are: BMP, GIF, JPEG, PNG, PPM, SRF, TIFF, DICOM. A GUI is provided to enter the parameters.
Parameters
| prefix | string(required) | A string specifying the prefix of the images to read included the path, for example "/home/data/images/Image" |
| suffix | string(required) | A string specifying the suffix of the images to read, for example "jpg" |
| n_start | integer(required) | An integer specifying the first image in the sequence |
| n_end | integer(required) | An integer specifying the last image in the sequence |
| digits | integer(required) | An integer specifying the number of digits of the number field in the sequence, for example image00001.jpg would require digits=5 |
| xsize | integer(optional) | An integer specifying the x size of the output image. If not specified the size of the first image is used. |
| ysize | integer(optional) | An integer specifying the y size of the output image. If not specified the size of the first image is used. |
| format | integer(optional) | An integer with values 0 for MPEG1 and 1 for MPEG2. Default is MPEG1 |
| frame_rate | integer(optional) | An integer with values |
| 1 = 23.976 frames/sec: NTSC encapsulated film rate | ||
| 2 = 24 frames/sec: standard film rate | ||
| 3 = 25 frames/sec: PAL video frame rate | ||
| 4 = 29.97 frames/sec: NTSC video frame rate | ||
| 5 = 30 frames/sec: NTSC drop frame video rate (the default) | ||
| 6 = 50 frames/sec: double frame rate/progressive PAL | ||
| 7 = 59.94 frames/sec: double frame rate NTSC | ||
| 8 = 60 frames/sec: double frame rate NTSC | ||
| mpeg_file | string(optional) | A string specifying the output MPEG file (default outfile.mpg) |
| tmp_dir | string(optional) | A string specifying temporary directory to use for the temporary image files |
After unzipping and untaring the files please refer to the README file for running the project.