|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ca.randelshofer.AVIOutputStream
public class AVIOutputStream
This class supports writing of images into an AVI 1.0 video file.
The images are written as video frames.
Video frames can be encoded with one of the following formats:
All frames in an AVI file must have the same duration. The duration can
be set by setting an appropriate pair of values using methods
setFrameRate(int)
and setTimeScale(int)
.
The length of an AVI 1.0 file is limited to 1 GB. This class supports lengths of up to 4 GB, but such files may not work on all players.
For detailed information about the AVI RIFF file format see:
msdn.microsoft.com AVI RIFF
www.microsoft.com FOURCC for Video Compression
www.saettler.com RIFF
Nested Class Summary | |
---|---|
static class |
AVIOutputStream.VideoFormat
Supported video encodings. |
Constructor Summary | |
---|---|
AVIOutputStream(java.io.File file,
AVIOutputStream.VideoFormat format)
Creates a new AVI file with the specified video format and frame rate. |
|
AVIOutputStream(java.io.File file,
AVIOutputStream.VideoFormat format,
int bitsPerPixel)
Creates a new AVI file with the specified video format and frame rate. |
|
AVIOutputStream(javax.imageio.stream.ImageOutputStream out,
AVIOutputStream.VideoFormat format)
Creates a new AVI output stream with the specified video format and framerate. |
Method Summary | |
---|---|
void |
close()
Closes the movie file as well as the stream being filtered. |
void |
finish()
Finishes writing the contents of the AVI output stream without closing the underlying stream. |
int |
getFrameRate()
Returns the frame rate of this media. |
int |
getTimeScale()
Returns the time scale of this media. |
float |
getVideoCompressionQuality()
Returns the video compression quality. |
java.awt.Dimension |
getVideoDimension()
Gets the dimension of the video track. |
void |
setFrameRate(int newValue)
Sets the rate of video frames in time scale units. |
void |
setPalette(java.awt.image.IndexColorModel palette)
Sets the global color palette. |
void |
setTimeScale(int newValue)
Used with frameRate to specify the time scale that this stream will use. |
void |
setVideoCompressionQuality(float newValue)
Sets the compression quality of the video track. |
void |
setVideoDimension(int width,
int height)
Sets the dimension of the video track. |
void |
writeFrame(java.awt.image.BufferedImage image)
Writes a frame to the video track. |
void |
writeFrame(java.io.File file)
Writes a frame from a file to the video track. |
void |
writeFrame(java.io.InputStream in)
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 |
---|
public AVIOutputStream(java.io.File file, AVIOutputStream.VideoFormat format) throws java.io.IOException
file
- the output fileformat
- Selects an encoder for the video format.
java.lang.IllegalArgumentException
- if videoFormat is null or if
frame rate is <= 0
java.io.IOException
public AVIOutputStream(java.io.File file, AVIOutputStream.VideoFormat format, int bitsPerPixel) throws java.io.IOException
file
- the output fileformat
- Selects an encoder for the video format.bitsPerPixel
- the number of bits per pixel.
java.lang.IllegalArgumentException
- if videoFormat is null or if
frame rate is <= 0
java.io.IOException
public AVIOutputStream(javax.imageio.stream.ImageOutputStream out, AVIOutputStream.VideoFormat format) throws java.io.IOException
out
- the underlying output streamformat
- Selects an encoder for the video format.
java.lang.IllegalArgumentException
- if videoFormat is null or if
framerate is <= 0
java.io.IOException
Method Detail |
---|
public void setTimeScale(int newValue)
The default value is 1.
newValue
- public int getTimeScale()
public void setFrameRate(int newValue)
The default value is 30. Together with the default value 1 of timeScale this results in 30 frames pers second.
newValue
- public int getFrameRate()
public void setPalette(java.awt.image.IndexColorModel palette)
public void setVideoCompressionQuality(float newValue)
Changing this value affects frames which are subsequently written to the AVIOutputStream. Frames which have already been written are not changed.
This value has only effect on videos encoded with JPG format.
The default value is 0.9.
newValue
- public float getVideoCompressionQuality()
public void setVideoDimension(int width, int height)
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 AVIOutputStream can determine the video dimension from the image width and height.
width
- Must be greater than 0.height
- Must be greater than 0.public java.awt.Dimension getVideoDimension()
Returns null if the dimension is not known.
public void writeFrame(java.awt.image.BufferedImage image) throws java.io.IOException
If the dimension of the video track has not been specified yet, it is derived from the first buffered image added to the AVIOutputStream.
image
- The frame image.
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 image failed.public void writeFrame(java.io.File file) throws java.io.IOException
This method does not inspect the contents of the file. For example, Its 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().
file
- The file which holds the image data.
java.lang.IllegalStateException
- if the duration is less than 1.
java.io.IOException
- if writing the image failed.public void writeFrame(java.io.InputStream in) throws java.io.IOException
This method does not inspect the contents of the file. For example, its 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().
in
- The input stream which holds the image data.
java.lang.IllegalArgumentException
- if the duration is less than 1.
java.io.IOException
- if writing the image failed.public void close() throws java.io.IOException
java.io.IOException
- if an I/O error has occurredpublic void finish() throws java.io.IOException
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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |