Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## sim.util.media
Class MovieEncoder

    java.lang.Object
      sim.util.media.MovieEncoder

All Implemented Interfaces:
  java.io.Serializable

public class MovieEncoder
extends java.lang.Object
implements java.io.Serializable

Usage of this class depends on the existence of the Java Media Framework (JMF) which can be acquired from javasoft.com. The class was tested on JMF 2.1.1.

This class encodes BufferedImages into quicktime movies. It has three main functions:

First, you call getEncodingFormats(), which returns an array of available formats. You specify a frame rate and a prototypical image.

Then, you call the constructor -- specify the frame rate, file, an encoding format chosen from the array in getEncodingFormats, and again provide a prototypical image. You'll want to ensure that future images encoded into the MovieEncoder will have the same size and format as the prototype image. If not, they'll be converted and cropped accordingly, which will take more time. You should expect the constructor to take a few seconds to start up -- JMF is not speedy.

Then you drop images into the MovieEncoder to add to the Quicktime movie as frames, using the add(BufferedImage) method. If there was an error and the movie could not be written, this method (and all subsequent add(...) calls) will return false.

When you're all finished, you call the stop() method to clean up and complete writing the file.

See Also:
  Serialized Form

Constructor Summary
`MovieEncoder(float frameRate, java.io.File file, java.awt.image.BufferedImage typicalImage, Format encodeFormat)` Creates an object which will write out a move of the specified format, and written to the provided file.

Method Summary
`boolean` | `add(java.awt.image.BufferedImage i)` Adds an image to the movie.
`void` | `controllerUpdate(ControllerEvent evt)` Controller Listener.
`void` | `dataSinkUpdate(DataSinkEvent evt)` Event handler for the file writer.
`static Format[]` | `getEncodingFormats(float fps, java.awt.image.BufferedImage typicalImage)` Returns null and prints an error out to stderr if an error occurred while trying to get the formats
`boolean` | `stop()` Stops the writer and finishes uprocessor.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MovieEncoder

    public MovieEncoder(float frameRate,
                        java.io.File file,
                        java.awt.image.BufferedImage typicalImage,
                        Format encodeFormat)

  Creates an object which will write out a move of the specified format, and written to the provided file.

Method Detail

### getEncodingFormats

    public static Format[] getEncodingFormats(float fps,
                                              java.awt.image.BufferedImage typicalImage)

  Returns null and prints an error out to stderr if an error occurred while trying to get the formats

### controllerUpdate

    public void controllerUpdate(ControllerEvent evt)

  Controller Listener.

### dataSinkUpdate

    public void dataSinkUpdate(DataSinkEvent evt)

  Event handler for the file writer.

### add

    public boolean add(java.awt.image.BufferedImage i)

  Adds an image to the movie. The very first image added will specify the size of the movie's frames and the image type for later images. You should strive to keep the images the same size, else MovieEncoder must will conver and crop them to the original image's format and size. Returns true if the image was successfully added. Returns false if we've been stopped (either intentionally or due to an error).

### stop

    public boolean stop()

  Stops the writer and finishes uprocessor. After this, this object cannot be used. It is possible that the system may take a second to write out and finish up

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD