Interface MovieWriter

All Superinterfaces:
AutoCloseable, Closeable, Multiplexer
All Known Implementing Classes:
AVIWriter, ImageSequenceWriter, QuickTimeWriter

public interface MovieWriter extends Multiplexer, AutoCloseable
A simple API for writing movie data (audio and video) into a file.
Author:
Werner Randelshofer
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    addTrack(Format format)
    Adds a track to the writer for a suggested input format.
    void
    Closes the writer.
    getDuration(int track)
    Returns the duration of the track in seconds.
    Returns the file format.
    getFormat(int track)
    Returns the media format of the specified track.
    int
    Returns the number of tracks.
    boolean
    Returns true if the limit for media data has been reached.
    boolean
    isEmpty(int track)
    Returns true if the specified track has no samples.
    void
    write(int track, Buffer buf)
    Writes a sample into the specified track.
  • Method Details

    • getFileFormat

      Format getFileFormat() throws IOException
      Returns the file format.
      Throws:
      IOException
    • addTrack

      int addTrack(Format format) throws IOException
      Adds a track to the writer for a suggested input format.

      The format should at least specify the desired FormatKeys.MediaType. The actual input format is a refined version of the suggested format. For example, if a MovieWriter only supports fixed frame rate video, then the MovieWriter will extend the format with that information.

      If the suggested input format is not compatible, then an IOException is thrown. For example, if a MovieWriter only supports fixed frame rate video, but a format with variable frame rate was requested.

      Specified by:
      addTrack in interface Multiplexer
      Parameters:
      format - The desired input format of the track. The actual input format may be a refined version of the specified format.
      Returns:
      The track number.
      Throws:
      IOException
    • getFormat

      Format getFormat(int track)
      Returns the media format of the specified track. This is a refined version of the format that was requested when the track was added. See addTrack(org.monte.media.av.Format).
      Parameters:
      track - Track number.
      Returns:
      The media format of the track.
    • getTrackCount

      int getTrackCount()
      Returns the number of tracks.
    • write

      void write(int track, Buffer buf) throws IOException
      Writes a sample into the specified track. Does nothing if the discard-flag in the buffer is set to true.
      Specified by:
      write in interface Multiplexer
      Parameters:
      track - The track number.
      buf - The buffer containing the sample data.
      Throws:
      IOException - if the write fails
    • close

      void close() throws IOException
      Closes the writer.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Multiplexer
      Throws:
      IOException - if close fails
    • isDataLimitReached

      boolean isDataLimitReached()
      Returns true if the limit for media data has been reached. If this limit is reached, no more samples should be added to the movie.

      This limit is imposed by data structures of the movie file which will overflow if more samples are added to the movie.

      FIXME - Maybe replace by getCapacity():long.

    • getDuration

      Rational getDuration(int track)
      Returns the duration of the track in seconds.
    • isEmpty

      boolean isEmpty(int track)
      Returns true if the specified track has no samples.