Copyright 2011-01-06 Werner Randelshofer

ch.randelshofer.media.quicktime
Class QuickTimeOutputStream

java.lang.Object
  extended by ch.randelshofer.media.quicktime.QuickTimeOutputStream

Deprecated. Use QuickTimeWriter instead of this class.

@Deprecated
public class QuickTimeOutputStream
extends java.lang.Object

Supports writing of images into a QuickTime movie file.

The images are written as video frames.

Video frames can be encoded with the RAW, the JPG or the PNG video format. All frames must have the same format. When JPG is used each frame can have an individual encoding quality.

Each frame in a QuickTime file can have an individual duration. The duration is based on time scale units, which can be specified using method setTimeScale(int).

For detailed information about the QuickTime file format see: http://developer.apple.com/documentation/QuickTime/QTFF/

Version:
1.3.2 2010-10-01 Changes "hdlr" "componentName" from cstring to pstring.
1.3.1 2010-07-19 Fixes seeking and calculation of offsets.
1.3 2010-07-08 Adds constructor with ImageOutputStream. Added method getVideoDimension().
1.2.1 2010-05-11 Fixes constructor comments.
1.2 2009-08-29 AddsRAW encoder.
1.1 2008-08-11 Streamlines source code and API with AVIOutputStream.
1.0.1 2008-06-18 WideDataAtom wrote incorrect header for atoms larger than 4 GB. The default value of time scale is now 600. Renamed method writeFrame to writeFrame. Added writeFrame methods which take a file or an input stream as argument.
1.0 Jun 15, 2008 Created.
Author:
Werner Randelshofer

Nested Class Summary
static class QuickTimeOutputStream.VideoFormat
          Deprecated. Supported video formats.
 
Constructor Summary
QuickTimeOutputStream(java.io.File file, QuickTimeOutputStream.VideoFormat format)
          Deprecated. Creates a new QuickTime file with the specified video format.
QuickTimeOutputStream(javax.imageio.stream.ImageOutputStream out, QuickTimeOutputStream.VideoFormat format)
          Deprecated. Creates a new QuickTime output stream with the specified video format.
 
Method Summary
 void close()
          Deprecated. Closes the movie file as well as the stream being filtered.
 void finish()
          Deprecated. Finishes writing the contents of the QuickTime output stream without closing the underlying stream.
 int getTimeScale()
          Deprecated. Returns the time scale of this media.
 float getVideoCompressionQuality()
          Deprecated. Returns the video compression quality.
 java.awt.Dimension getVideoDimension()
          Deprecated. Gets the dimension of the video track.
 void setTimeScale(int newValue)
          Deprecated. Sets the time scale for this media, that is, the number of time units that pass per second in its time coordinate system.
 void setVideoCompressionQuality(float newValue)
          Deprecated. Sets the compression quality of the video track.
 void setVideoDimension(int width, int height)
          Deprecated. Sets the dimension of the video track.
 void writeFrame(java.awt.image.BufferedImage image, int duration)
          Deprecated. Writes a frame to the video track.
 void writeFrame(java.io.File file, int duration)
          Deprecated. Writes a frame from a file to the video track.
 void writeFrame(java.io.InputStream in, int duration)
          Deprecated. Writes a frame to the video track.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuickTimeOutputStream

public QuickTimeOutputStream(java.io.File file,
                             QuickTimeOutputStream.VideoFormat format)
                      throws java.io.IOException
Deprecated. 
Creates a new QuickTime file with the specified video format.

Parameters:
file - the output file
format - Selects an encoder for the video format.
Throws:
java.lang.IllegalArgumentException - if format is null.
java.io.IOException

QuickTimeOutputStream

public QuickTimeOutputStream(javax.imageio.stream.ImageOutputStream out,
                             QuickTimeOutputStream.VideoFormat format)
                      throws java.io.IOException
Deprecated. 
Creates a new QuickTime output stream with the specified video format.

Parameters:
out - the underlying output stream.
format - Selects an encoder for the video format.
Throws:
java.lang.IllegalArgumentException - if format is null.
java.io.IOException
Method Detail

setTimeScale

public void setTimeScale(int newValue)
Deprecated. 
Sets the time scale for this media, that is, the number of time units that pass per second in its time coordinate system.

The default value is 600.

Parameters:
newValue -

getTimeScale

public int getTimeScale()
Deprecated. 
Returns the time scale of this media.

Returns:
time scale

setVideoCompressionQuality

public void setVideoCompressionQuality(float newValue)
Deprecated. 
Sets the compression quality of the video track. A value of 0 stands for "high compression is important" a value of 1 for "high image quality is important".

Changing this value affects frames which are subsequently written to the QuickTimeOutputStream. Frames which have already been written are not changed.

This value has no effect on videos encoded with the PNG format.

The default value is 0.95.

Parameters:
newValue -

getVideoCompressionQuality

public float getVideoCompressionQuality()
Deprecated. 
Returns the video compression quality.

Returns:
video compression quality

setVideoDimension

public void setVideoDimension(int width,
                              int height)
Deprecated. 
Sets the dimension of the video track.

You need to explicitly set the dimension, if you add all frames from files or input streams.

If you add frames from buffered images, then QuickTimeOutputStream can determine the video dimension from the image width and height.

Parameters:
width - Must be greater than 0.
height - Must be greater than 0.

getVideoDimension

public java.awt.Dimension getVideoDimension()
Deprecated. 
Gets the dimension of the video track.

Returns null if the dimension is not known.


writeFrame

public void writeFrame(java.awt.image.BufferedImage image,
                       int duration)
                throws java.io.IOException
Deprecated. 
Writes a frame to the video track.

If the dimension of the video track has not been specified yet, it is derived from the first buffered image added to the QuickTimeOutputStream.

Parameters:
image - The frame image.
duration - The duration of the frame in time scale units.
Throws:
java.lang.IllegalArgumentException - if the duration is less than 1, or if the dimension of the frame does not match the dimension of the video track.
java.io.IOException - if writing the data sample failed.

writeFrame

public void writeFrame(java.io.File file,
                       int duration)
                throws java.io.IOException
Deprecated. 
Writes a frame from a file to the video track.

This method does not inspect the contents of the file. The contents has to match the video format. For example, it is your responsibility to only add JPG files if you have chosen the JPEG video format.

If you add all frames from files or from input streams, then you have to explicitly set the dimension of the video track before you call finish() or close().

Parameters:
file - The file which holds the image data.
duration - The duration of the frame in time scale units.
Throws:
java.lang.IllegalArgumentException - if the duration is less than 1.
java.io.IOException - if writing the data sample failed.

writeFrame

public void writeFrame(java.io.InputStream in,
                       int duration)
                throws java.io.IOException
Deprecated. 
Writes a frame to the video track.

This method does not inspect the contents of the input stream. The contents has to match the video format. For example, it is your responsibility to only add JPG files if you have chosen the JPEG video format.

If you add all frames from files or from input streams, then you have to explicitly set the dimension of the video track before you call finish() or close().

Parameters:
in - The input stream which holds the image data.
duration - The duration of the frame in time scale units.
Throws:
java.lang.IllegalArgumentException - if the duration is less than 1.
java.io.IOException - if writing the image failed.

close

public void close()
           throws java.io.IOException
Deprecated. 
Closes the movie file as well as the stream being filtered.

Throws:
java.io.IOException - if an I/O error has occurred

finish

public void finish()
            throws java.io.IOException
Deprecated. 
Finishes writing the contents of the QuickTime output stream without closing the underlying stream. Use this method when applying multiple filters in succession to the same output stream.

Throws:
java.lang.IllegalStateException - if the dimension of the video track has not been specified or determined yet.
java.io.IOException - if an I/O exception has occurred

Copyright 2011-01-06 Werner Randelshofer