public class

MultiComposeBase

extends Object
java.lang.Object
   ↳ com.ksyun.media.shortvideo.kit.MultiComposeBase
Known Direct Subclasses

Class Overview

for compose multi files

Summary

Nested Classes
class MultiComposeBase.MediaContext  
Constants
float DEFAULT_IFRAME_INTERVAL
int DEFAULT_VIDEO_BIRATERATE
Fields
protected int mAudioChannels
protected int mAudioDecodeMethod
protected AudioMixer mAudioMixer
protected AVPtsFilter mAudioPtsFilter
protected Context mContext
protected int mCount
public FilePublisher.PubListener mFilePublisherListener
protected GLRender mGLRender
protected ImgTexFilterMgt mImgTexFilterMgt
protected ImgTexMixer mImgTexMixer
protected boolean mInit
protected Handler mMainHandler
protected List<MultiComposeBase.MediaContext> mMediaContexts
protected int mScaleMode
protected boolean mStopped
protected int mVideoDecodeMethod
protected AVPtsFilter mVideoPtsFilter
Public Constructors
MultiComposeBase(Context context)
Public Methods
int getAudioBitrate()
int getAudioEncodeProfile()
GLRender getGLRender()
Get GLRender instance.
ImgTexFilterMgt getImgTexFilterMgt()
Get ImgTexFilterMgt instance to manage GPU filters.
int getVideoBitrate()
int getVideoCodecId()
int getVideoEncodeMethod()
int getVideoEncodeProfile()
float getVideoFps()
void release()
void setAudioBitrate(int bitrate)
Set audio bitrate in bps.
void setAudioChannels(int channels)
Set audio channel number.
void setAudioDecodeMethod(int decodeMethod)
Set decode method for video.
void setAudioEncodeProfile(int profile)
Set audio encode profile.
void setAudioKBitrate(int kBitrate)
Set audio bitrate in kbps.
void setAudioSampleRate(int sampleRate)
Set audio sample rate while streaming.
void setAudioVolume(int idx, float leftVolume, float rightVolume)
void setDecodeMethod(int decodeMethod)
Set decode method for video and audio.
void setEnableMp4FastStart(boolean enable)
Run a second pass moving the index (moov atom) to the beginning of the mp4 file.
void setEncodeMethod(int encodeMethod)
Set encode method for both video and audio.
void setIFrameInterval(float interval)
void setOnBaseErrorListener(MultiComposeBase.OnErrorListener onErrorListener)
Set onErrorListener.
void setOnBaseInfoListener(MultiComposeBase.OnInfoListener onInfoListener)
Set OnInfoListener.
void setScaleMode(int scaleMode)
set scale mode
void setTargetResolution(int width, int height)
Set transcode target resolution.
void setVideoBitrate(int bitrate)
Set video bitrate in bps, and disable video bitrate auto adjustment.
void setVideoCodecId(int codecId)
Set codec id to video encoder.
void setVideoCrf(int crf)
set Constant Rate Factor
void setVideoDecodeMethod(int decodeMethod)
Set decode method for video.
void setVideoEncodeMethod(int encodeMethod)
Set encode method for video.
void setVideoEncodeProfile(int profile)
Set encode profile to video encoder.
void setVideoFps(float fps)
Sets video fps.
void setVideoKBitrate(int kBitrate)
Set video bitrate in kbps, and disable video bitrate auto adjustment.
Protected Methods
void abort()
void config(MultiComposeBase.MediaContext context)
void config(MultiComposeBase.MediaContext context, int index)
main MediaContext
MultiComposeBase.MediaContext createMediaContext(boolean isMain)
void setAudioParams()
boolean startCompose(String desUrl, int checkAuthFeature)
void stopCompose()
中止合成
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final float DEFAULT_IFRAME_INTERVAL

Constant Value: 1.0

public static final int DEFAULT_VIDEO_BIRATERATE

Constant Value: 4000000 (0x003d0900)

Fields

protected int mAudioChannels

protected int mAudioDecodeMethod

protected AudioMixer mAudioMixer

protected AVPtsFilter mAudioPtsFilter

protected Context mContext

protected int mCount

public FilePublisher.PubListener mFilePublisherListener

protected GLRender mGLRender

protected ImgTexFilterMgt mImgTexFilterMgt

protected ImgTexMixer mImgTexMixer

protected boolean mInit

protected Handler mMainHandler

protected List<MultiComposeBase.MediaContext> mMediaContexts

protected int mScaleMode

protected boolean mStopped

protected int mVideoDecodeMethod

protected AVPtsFilter mVideoPtsFilter

Public Constructors

public MultiComposeBase (Context context)

Public Methods

public int getAudioBitrate ()

public int getAudioEncodeProfile ()

public GLRender getGLRender ()

Get GLRender instance.

Returns
  • GLRender instance.

public ImgTexFilterMgt getImgTexFilterMgt ()

Get ImgTexFilterMgt instance to manage GPU filters.

Returns
  • ImgTexFilterMgt instance.

public int getVideoBitrate ()

public int getVideoCodecId ()

public int getVideoEncodeMethod ()

public int getVideoEncodeProfile ()

public float getVideoFps ()

public void release ()

public void setAudioBitrate (int bitrate)

Set audio bitrate in bps.

Parameters
bitrate audio bitrate in bps.
Throws
IllegalArgumentException

public void setAudioChannels (int channels)

Set audio channel number.
default value : 1

Parameters
channels audio channel number, 1 for mono, 2 for stereo, 0 for input config.
Throws
IllegalArgumentException

public void setAudioDecodeMethod (int decodeMethod)

Set decode method for video.
Must not be set while decoding.

Parameters
decodeMethod Decode method.
Throws
IllegalStateException
IllegalArgumentException
IllegalStateException
See Also
  • StreamerConstants#DECODE_METHOD_SOFTWARE
  • StreamerConstants#DECODE_METHOD_HARDWARE

public void setAudioEncodeProfile (int profile)

Set audio encode profile.

Parameters
profile profile to set.
See Also
  • AVConst#PROFILE_AAC_LOW
  • AVConst#PROFILE_AAC_HE
  • AVConst#PROFILE_AAC_HE_V2

public void setAudioKBitrate (int kBitrate)

Set audio bitrate in kbps.

Parameters
kBitrate audio bitrate in kbps.
Throws
IllegalArgumentException

public void setAudioSampleRate (int sampleRate)

Set audio sample rate while streaming.
default value 44100

Parameters
sampleRate sample rate in Hz.
Throws
IllegalArgumentException

public void setAudioVolume (int idx, float leftVolume, float rightVolume)

public void setDecodeMethod (int decodeMethod)

Set decode method for video and audio.
Must not be set while decoding.

Parameters
decodeMethod Decode method.
Throws
IllegalStateException
IllegalArgumentException
IllegalStateException
See Also
  • StreamerConstants#DECODE_METHOD_SOFTWARE
  • StreamerConstants#DECODE_METHOD_HARDWARE

public void setEnableMp4FastStart (boolean enable)

Run a second pass moving the index (moov atom) to the beginning of the mp4 file.

This operation can take a while, and will not work in various situations such as fragmented output, thus it is not enabled by default.

Parameters
enable true to enable, false to disable

public void setEncodeMethod (int encodeMethod)

Set encode method for both video and audio.
Must not be set while encoding. default value:ENCODE_METHOD_SOFTWARE

Parameters
encodeMethod Encode method.
Throws
IllegalStateException
IllegalArgumentException
IllegalStateException
See Also
  • StreamerConstants#ENCODE_METHOD_SOFTWARE
  • StreamerConstants#ENCODE_METHOD_SOFTWARE_COMPAT
  • StreamerConstants#ENCODE_METHOD_HARDWARE

public void setIFrameInterval (float interval)

Parameters
interval I frame interval

public void setOnBaseErrorListener (MultiComposeBase.OnErrorListener onErrorListener)

Set onErrorListener.

Parameters
onErrorListener error callback

public void setOnBaseInfoListener (MultiComposeBase.OnInfoListener onInfoListener)

Set OnInfoListener.

Parameters
onInfoListener info callback

public void setScaleMode (int scaleMode)

set scale mode

See Also
  • ImgTexScaleFilter#SCALING_MODE_BEST_FIT
  • ImgTexScaleFilter#SCALING_MODE_FULL_FILL
  • ImgTexScaleFilter#SCALING_MODE_CENTER_CROP

public void setTargetResolution (int width, int height)

Set transcode target resolution.

The set resolution would take effect immediately if compose started.

The set width and height must not be 0 at same time. If one of the params is 0, the other would calculated by the actual preview view size to keep the ratio of the preview view.

Parameters
width streaming width.
height streaming height.
Throws
IllegalArgumentException

public void setVideoBitrate (int bitrate)

Set video bitrate in bps, and disable video bitrate auto adjustment.

Parameters
bitrate video bitrate in bps
Throws
IllegalArgumentException

public void setVideoCodecId (int codecId)

Set codec id to video encoder.

Parameters
codecId video codec id to set.
Throws
IllegalArgumentException
See Also
  • AVConst#CODEC_ID_AVC
  • AVConst#CODEC_ID_HEVC

public void setVideoCrf (int crf)

set Constant Rate Factor

public void setVideoDecodeMethod (int decodeMethod)

Set decode method for video.
Must not be set while decoding.

Parameters
decodeMethod Decode method.
Throws
IllegalStateException
IllegalArgumentException
IllegalStateException
See Also
  • StreamerConstants#DECODE_METHOD_SOFTWARE
  • StreamerConstants#DECODE_METHOD_HARDWARE

public void setVideoEncodeMethod (int encodeMethod)

Set encode method for video.
Must not be set while encoding.

Parameters
encodeMethod Encode method.
Throws
IllegalStateException
IllegalArgumentException
IllegalStateException
See Also
  • StreamerConstants#ENCODE_METHOD_SOFTWARE
  • StreamerConstants#ENCODE_METHOD_SOFTWARE_COMPAT
  • StreamerConstants#ENCODE_METHOD_HARDWARE

public void setVideoEncodeProfile (int profile)

Set encode profile to video encoder.

Only valid in ENCODE_METHOD_SOFTWARE and ENCODE_METHOD_SOFTWARE_COMPAT mode.

Parameters
profile encode profile mode to be set, default value VideoEncodeFormat#ENCODE_PROFILE_LOW_POWER
See Also
  • VideoEncodeFormat#ENCODE_PROFILE_LOW_POWER
  • VideoEncodeFormat#ENCODE_PROFILE_BALANCE
  • VideoEncodeFormat#ENCODE_PROFILE_HIGH_PERFORMANCE

public void setVideoFps (float fps)

Sets video fps.

Parameters
fps the fps

public void setVideoKBitrate (int kBitrate)

Set video bitrate in kbps, and disable video bitrate auto adjustment.

Parameters
kBitrate video bitrate in kbps
Throws
IllegalArgumentException

Protected Methods

protected void abort ()

protected void config (MultiComposeBase.MediaContext context)

protected void config (MultiComposeBase.MediaContext context, int index)

main MediaContext

protected MultiComposeBase.MediaContext createMediaContext (boolean isMain)

protected void setAudioParams ()

protected boolean startCompose (String desUrl, int checkAuthFeature)

protected void stopCompose ()

中止合成