Class MediaEncoder


public class MediaEncoder extends MediaFormat
Media encoder. TODO : deprecate class New code should use MediaOutput instead.
Author:
pquiring
  • Field Details

    • fps_1000_1001

      public boolean fps_1000_1001
    • framesPerKeyFrame

      public int framesPerKeyFrame
    • videoBitRate

      public int videoBitRate
    • audioBitRate

      public int audioBitRate
    • compressionLevel

      public int compressionLevel
    • profileLevel

      public int profileLevel
  • Constructor Details

    • MediaEncoder

      public MediaEncoder()
  • Method Details

    • start

      public boolean start(MediaIO io, int width, int height, int fps, int chs, int freq, String format, boolean doVideo, boolean doAudio)
      Start encoder. Uses default codec for format.
      Parameters:
      io - = MediaIO interface
      width - = width of video (-1 = no video)
      height - = height of video (-1 = no video)
      fps - = frames per second (-1 = no video)
      chs - = audio channels (-1 = no audio)
      freq - = audio frequency (-1 = no audio)
      format - = audio format (see MediaCoder.AV_FORMAT_...)
      doVideo - = enable video stream
      doAudio - = enable audio stream
    • start

      public boolean start(MediaIO io, int width, int height, int fps, int chs, int freq, String format, int video_codec, int audio_codec)
      Start encoder.
      Parameters:
      io - = MediaIO interface
      width - = width of video (-1 = no video)
      height - = height of video (-1 = no video)
      fps - = frames per second (-1 = no video)
      chs - = audio channels (-1 = no audio)
      freq - = audio frequency (-1 = no audio)
      format - = audio format (see MediaCoder.AV_FORMAT_...)
      video_codec - = video codec to use (-1 = default for format, 0 = no video stream) (see MediaFormat.AV_CODEC_...)
      audio_codec - = audio codec to use (-1 = default for format, 0 = no video stream) (see MediaFormat.AV_CODEC_...)
    • startFile

      public boolean startFile(String file, int width, int height, int fps, int chs, int freq, String format, int video_codec, int audio_codec)
      Start encoder.
      Parameters:
      file - = filename to save to.
      width - = width of video (-1 = no video)
      height - = height of video (-1 = no video)
      fps - = frames per second (-1 = no video)
      chs - = audio channels (-1 = no audio)
      freq - = audio frequency (-1 = no audio)
      format - = audio format (see MediaCoder.AV_FORMAT_...)
      video_codec - = video codec to use (-1 = default for format, 0 = no video stream) (see MediaCoder.AV_CODEC_...)
      audio_codec - = audio codec to use (-1 = default for format, 0 = no video stream) (see MediaCoder.AV_CODEC_...)
    • set1000over1001

      public void set1000over1001(boolean state)
      Sets frame rate = fps * 1000 / 1001 (default = false)
    • setFramesPerKeyFrame

      public void setFramesPerKeyFrame(int count)
      Sets frames per key frame (gop) (default = 12)
    • setVideoBitRate

      public void setVideoBitRate(int rate)
      Sets video bit rate (default = 400000 bits/sec)
    • setAudioBitRate

      public void setAudioBitRate(int rate)
      Sets audio bit rate (default = 128000 bits/sec)
    • setCompressionLevel

      public void setCompressionLevel(int level)
      Sets compression level (meaning varies per codec) (default = -1)
    • setProfileLevel

      public void setProfileLevel(int level)
      Sets profile level (1=baseline 2=main 3=pro)
    • addAudio

      public boolean addAudio(short[] sams, int offset, int length)
    • addAudio

      public boolean addAudio(short[] sams)
    • addVideo

      public boolean addVideo(int[] px)
    • getAudioFramesize

      public int getAudioFramesize()
    • getLastDTS

      public long getLastDTS()
    • getLastPTS

      public long getLastPTS()
    • addAudioEncoded

      public boolean addAudioEncoded(byte[] packet, int offset, int length)
      Adds pre encoded audio.
    • addVideoEncoded

      public boolean addVideoEncoded(byte[] packet, int offset, int length, boolean key_frame)
      Adds pre encoded video.
    • addAudioEncodedTS

      public boolean addAudioEncodedTS(byte[] packet, int offset, int length, long dts, long pts)
      Adds pre encoded audio.
    • addVideoEncodedTS

      public boolean addVideoEncodedTS(byte[] packet, int offset, int length, boolean key_frame, long dts, long pts)
      Adds pre encoded video.
    • flush

      public void flush()
    • stop

      public void stop()
    • getCodecMimeType

      public String getCodecMimeType(String codec, boolean doVideo, boolean doAudio)
      Returns codecs mimetype.