Class MediaEncoder
java.lang.Object
javaforce.media.MediaCoder
javaforce.media.MediaFormat
javaforce.media.MediaEncoder
Media encoder.
TODO : deprecate class
New code should use MediaOutput instead.
- Author:
- pquiring
-
Field Summary
FieldsModifier and TypeFieldDescriptionintintbooleanintintintFields inherited from class javaforce.media.MediaCoder
AUDIO_FRAME, AV_CODEC_ID_AAC, AV_CODEC_ID_AC3, AV_CODEC_ID_DEFAULT, AV_CODEC_ID_FLAC, AV_CODEC_ID_GSM_MS, AV_CODEC_ID_H263, AV_CODEC_ID_H264, AV_CODEC_ID_H265, AV_CODEC_ID_MP2, AV_CODEC_ID_MP3, AV_CODEC_ID_MPEG1VIDEO, AV_CODEC_ID_MPEG2VIDEO, AV_CODEC_ID_MPEG4, AV_CODEC_ID_NONE, AV_CODEC_ID_OPUS, AV_CODEC_ID_PCM_S16LE, AV_CODEC_ID_SPEEX, AV_CODEC_ID_THEORA, AV_CODEC_ID_VORBIS, AV_CODEC_ID_VP8, AV_CODEC_ID_VP9, AV_FORMAT_ID_AVI, AV_FORMAT_ID_MKV, AV_FORMAT_ID_MOV, AV_FORMAT_ID_MP1, AV_FORMAT_ID_MP2, AV_FORMAT_ID_MP4, AV_FORMAT_ID_OGG, AV_FORMAT_ID_WAV, AV_FORMAT_ID_WEBM, ctx, END_FRAME, NULL_FRAME, PROFILE_BASELINE, PROFILE_HIGH, PROFILE_MAIN, SEEK_CUR, SEEK_END, SEEK_SET, shared, VIDEO_FRAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddAudio(short[] sams) booleanaddAudio(short[] sams, int offset, int length) booleanaddAudioEncoded(byte[] packet, int offset, int length) Adds pre encoded audio.booleanaddAudioEncodedTS(byte[] packet, int offset, int length, long dts, long pts) Adds pre encoded audio.booleanaddVideo(int[] px) booleanaddVideoEncoded(byte[] packet, int offset, int length, boolean key_frame) Adds pre encoded video.booleanaddVideoEncodedTS(byte[] packet, int offset, int length, boolean key_frame, long dts, long pts) Adds pre encoded video.voidflush()intgetCodecMimeType(String codec, boolean doVideo, boolean doAudio) Returns codecs mimetype.longlongvoidset1000over1001(boolean state) Sets frame rate = fps * 1000 / 1001 (default = false)voidsetAudioBitRate(int rate) Sets audio bit rate (default = 128000 bits/sec)voidsetCompressionLevel(int level) Sets compression level (meaning varies per codec) (default = -1)voidsetFramesPerKeyFrame(int count) Sets frames per key frame (gop) (default = 12)voidsetProfileLevel(int level) Sets profile level (1=baseline 2=main 3=pro)voidsetVideoBitRate(int rate) Sets video bit rate (default = 400000 bits/sec)booleanstart(MediaIO io, int width, int height, int fps, int chs, int freq, String format, boolean doVideo, boolean doAudio) Start encoder.booleanstart(MediaIO io, int width, int height, int fps, int chs, int freq, String format, int video_codec, int audio_codec) Start encoder.booleanstartFile(String file, int width, int height, int fps, int chs, int freq, String format, int video_codec, int audio_codec) Start encoder.voidstop()Methods inherited from class javaforce.media.MediaFormat
getAudioBitRate, getAudioCodecID, getAudioStream, getVideoBitRate, getVideoCodecID, getVideoStreamMethods inherited from class javaforce.media.MediaCoder
getStream, init, isRunning, setLogging, setStream
-
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 interfacewidth- = 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 streamdoAudio- = 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 interfacewidth- = 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
-