Class Media

java.lang.Object
javaforce.media.Media

public class Media extends Object
  • Field Details

    • debug

      public static boolean debug
  • Constructor Details

    • Media

      public Media()
  • Method Details

    • open

      public boolean open(String file)
      Open existing file for reading.
    • create

      public boolean create(String file, int[] streamIDs, CodecInfo info)
      Create new file for writing. If file exists it is truncated. CodecInfo should contain information about audio/video format.
    • create

      public boolean create(String file, int[] streamIDs)
      Create new file for writing. If file exists it is truncated.
    • append

      public boolean append(String file)
      Open existing file to writing.
    • close

      public boolean close()
      If file was created or appended an index table is written at end of file for fast seeking.
    • getStreamIDs

      public int[] getStreamIDs()
      Return stream IDs.
    • getKeyFrameCount

      public int getKeyFrameCount()
      Return # of key frames.
    • getAllFrameCount

      public int getAllFrameCount()
      Return # of all frames.
    • getTimeBase

      public long getTimeBase()
      Returns timestamp of first frame.
    • getCodecInfo

      public CodecInfo getCodecInfo()
      Returns codec info that describes the media (optional).
    • seekFrame

      public boolean seekFrame(int frame)
      Seek to frame #. Seeking is not supported on files opened for writing (create() or append()).
    • seekTime

      public boolean seekTime(long ts)
      Seek to frame closest to timestamp.
    • readFrame

      public Packet readFrame()
      Read next Frame. Do not modify fields in Packet.
      Returns:
      frame = next frame or null at end of file or error
    • writeFrame

      public boolean writeFrame(int stream, byte[] data, int offset, int length, long ts, boolean keyFrame)
      Write next frame.
      Parameters:
      stream - = stream index
      data - = raw codec data
      offset - = offset into data
      length - = length of data
      ts - = timestamp of frame
      keyFrame - = is frame a key frame?
    • main

      public static void main(String[] args)
      Unit testing.