Class AVIReader

All Implemented Interfaces:
AutoCloseable, MovieReader

public class AVIReader extends AVIInputStream implements MovieReader
Provides high-level support for decoding and reading audio and video samples from an AVI 1.0 file.
Author:
Werner Randelshofer
  • Field Details

    • AVI

      public static final Format AVI
  • Constructor Details

  • Method Details

    • getFileFormat

      public Format getFileFormat() throws IOException
      Description copied from interface: MovieReader
      Returns the file format.
      Specified by:
      getFileFormat in interface MovieReader
      Throws:
      IOException
    • getFormat

      public Format getFormat(int track) throws IOException
      Description copied from interface: MovieReader
      Returns the media format of the specified track.
      Specified by:
      getFormat in interface MovieReader
      Parameters:
      track - Track number.
      Returns:
      The media format of the track.
      Throws:
      IOException
    • read

      public void read(int track, Buffer buffer) throws IOException
      Reads a chunk of media data from the specified track.

      If the track is a video track with palette change "..PC" chunks, then the body of the palette change chunk can be found in the buffer.header.

      Specified by:
      read in interface MovieReader
      Parameters:
      track - The track number.
      buffer - The buffer for the media data.
      Throws:
      IOException
    • read

      public BufferedImage read(int track, BufferedImage img) throws IOException
      Reads an image.
      Parameters:
      track - The track number
      img - An image that can be reused if it fits the media format of the track. Pass null to create a new image on each read.
      Returns:
      An image or null if the end of the media has been reached.
      Throws:
      IOException
    • getReadTime

      public Rational getReadTime(int track) throws IOException
      Description copied from interface: MovieReader
      Returns the current time of the track.
      Specified by:
      getReadTime in interface MovieReader
      Throws:
      IOException
    • nextTrack

      public int nextTrack() throws IOException
      Description copied from interface: MovieReader
      Returns the index of the next track in playback sequence.
      Specified by:
      nextTrack in interface MovieReader
      Returns:
      Index of next track or -1 if end of media reached.
      Throws:
      IOException
    • getDuration

      public Rational getDuration()
      Description copied from interface: MovieReader
      Returns the total duration of the movie .
      Specified by:
      getDuration in interface MovieReader
    • getDuration

      public Rational getDuration(int track)
      Description copied from interface: MovieReader
      Returns the duration of the specified track.
      Specified by:
      getDuration in interface MovieReader
    • getTimeScale

      public long getTimeScale(int track)
      Description copied from class: AVIInputStream
      Returns the time scale of the specified track.
      Overrides:
      getTimeScale in class AVIInputStream
    • timeToSample

      public long timeToSample(int track, Rational time)
      Description copied from interface: MovieReader
      Returns the sample number for the specified time.
      Specified by:
      timeToSample in interface MovieReader
    • sampleToTime

      public Rational sampleToTime(int track, long sampleIndex) throws IOException
      Description copied from interface: MovieReader
      Returns the time for the specified sample number.
      Specified by:
      sampleToTime in interface MovieReader
      Throws:
      IOException
    • setMovieReadTime

      public void setMovieReadTime(Rational newValue) throws IOException
      Description copied from interface: MovieReader
      Sets the read time of all tracks to the closest sync sample before or at the specified time.
      Specified by:
      setMovieReadTime in interface MovieReader
      Parameters:
      newValue - Time in seconds.
      Throws:
      IOException
    • findTrack

      public int findTrack(int fromTrack, Format format) throws IOException
      Description copied from interface: MovieReader
      Finds a track with the specified format.
      Specified by:
      findTrack in interface MovieReader
      Parameters:
      fromTrack - the start track number.
      format - A format specification.
      Returns:
      The track number >= fromTrack or -1 if no track has been found.
      Throws:
      IOException