Playing a Motion JPEG2000 Animation

You can use the IDLffMJPEG2000 object to access frames sequentially or randomly from a Motion JPEG2000 file (MJ2). Sequential access plays an animation, which can consist of entire frames, or can consist of frame components, tiles or regions, and uses a background processing thread. Random access plays selected frames, which can also consist of entire frames, or frame components, tiles or regions, without the use of a background processing thread. See the following sections for details:

Regardless of the type of playback, it is important to understand that unless you implement a timer mechanism to control playback, the default rate will be as fast as the frames can be decompressed. Options for timer mechanisms include widget timer and the more robust IDLitWindow timer mechanism.

Warning
Avoid using the WAIT procedure to control the sequential playback rate. On UNIX platforms there is an internal conflict between the background processing thread and the WAIT procedure. To avoid cross-platform compatibility issues, always use a widget timer or IDLitWindow timer mechanism to control the sequential playback rate.

The timer mechanism will typically use the FRAME_PERIOD and TIMESCALE properties to control the rate. See Controlling the Playback Rate for more information.

Note
If you find the rate at which the frames can be decompressed is slower than the desired playback speed, see High Speed Sequential Playback for an optional playback method.

Sequential Motion JPEG2000 Playback

To playback a large series of MJ2 frames, components, tiles or regions sequentially, your program will need to include the following methods and elements:

When playback ends, turn off the timer mechanism to stop the animation.

Examples showing the use of the sequential playback methods are located in Controlling the Playback Rate and the Examples section of "IDLffMJPEG2000::GetSequentialData" (IDL Reference Guide).

Random Motion JPEG2000 Playback

To access a specified frame, use the IDLffMJPEG2000::GetData method. When using GetData, you can return an entire frame, or a component, tile, or region of a frame. You can also specify the resolution (level) of data to return.

The GetData method returns data when it has been decompressed. Unlike GetSequentialData, GetData does not use a background processing thread and there is no frame buffer involved. This means that the data returned by GetData can be accessed. (The data returned by GetSequentialData cannot be accessed as it returns only a pointer to the data on the frame buffer.) Since no background processing thread is involved, a simple WAIT statement can be used to control the playback rate when there is no need to implement a more robust timer mechanism.

Use GetData when you need to access a small number of distinct frames. Use GetSequentialData and the background processing thread when you want to playback a large number of frames at a specified rate as described in Sequential Motion JPEG2000 Playback.

Simple examples that use the GetData method are described in Adding Data to MJ2 Animations.