Class Media

java.lang.Object
javaforce.media.Media

public class Media extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    append(String file)
    Open existing file to writing.
    boolean
    If file was created or appended an index table is written at end of file for fast seeking.
    boolean
    create(String file, int[] streamIDs)
    Create new file for writing.
    boolean
    create(String file, int[] streamIDs, CodecInfo info)
    Create new file for writing.
    int
    Return # of all frames.
    Returns codec info that describes the media (optional).
    int
    Return # of key frames.
    int[]
    Return stream IDs.
    long
    Returns timestamp of first frame.
    static void
    main(String[] args)
    Unit testing.
    boolean
    open(String file)
    Open existing file for reading.
    Read next Frame.
    boolean
    seekFrame(int frame)
    Seek to frame #.
    boolean
    seekTime(long ts)
    Seek to frame closest to timestamp.
    boolean
    writeFrame(int stream, byte[] data, int offset, int length, long ts, boolean keyFrame)
    Write next frame.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.