public class

KSYMergeKit

extends Object
java.lang.Object
   ↳ com.ksyun.media.shortvideo.kit.KSYMergeKit

Class Overview

transcode multiple video and merge into one

Summary

Constants
int ERROR_MERGE_EMPTY
int ERROR_MERGE_FAILED
int ERROR_TRANSCODE_FAILED
int INFO_MERGE_FINISH
int INFO_TRANSCODE_STARTED
int INFO_TRANSCODE_STOPBYUSERS
int INFO_TRANSCODE_UNSUPPORT
Public Constructors
KSYMergeKit(Context context)
Public Methods
int getCurrentTransFileId()
get current transcoding files id
float getTranscodeProgress()
get current transcoding files progress
void release()
void setAudioBitrate(int bitrate)
Set compose audio bitrate in bps.
void setAudioChannels(int channels)
Set audio channel number.
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 setEncodeMethod(int encodeMethod)
Set encode method for both video and audio.
void setIFrameInterval(float interval)
void setOnErrorListener(KSYMergeKit.OnErrorListener onErrorListener)
void setOnInfoListener(KSYMergeKit.OnInfoListener onInfoListener)
void setScaleMode(int scaleMode)
void setTargetResolution(int width, int height)
Set transcode target size.
void setToTranscodeFiles(Map<String, Boolean> toTranscodeFiles)
void setVideoBitrate(int bitrate)
Set merge video bitrate in bps
do not set during merging default value : 600 * 1000
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 setVideoFps(float fps)
Sets video fps.
void setVideoKBitrate(int kBitrate)
Set video bitrate in kbps
void setVideoProfile(int videoProfile)
Set encode profile to video encoder.
void start(List<String> srcFiles, String outputFile, String transCodeTmpDir, boolean autoDeleteTmpDir)
start transcode and merge
void stop()
stop transcode and merge
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ERROR_MERGE_EMPTY

Constant Value: 101 (0x00000065)

public static final int ERROR_MERGE_FAILED

Constant Value: -100 (0xffffff9c)

public static final int ERROR_TRANSCODE_FAILED

Constant Value: -1 (0xffffffff)

public static final int INFO_MERGE_FINISH

Constant Value: 100 (0x00000064)

public static final int INFO_TRANSCODE_STARTED

Constant Value: 3 (0x00000003)

public static final int INFO_TRANSCODE_STOPBYUSERS

Constant Value: 2 (0x00000002)

public static final int INFO_TRANSCODE_UNSUPPORT

Constant Value: 1 (0x00000001)

Public Constructors

public KSYMergeKit (Context context)

Public Methods

public int getCurrentTransFileId ()

get current transcoding files id

public float getTranscodeProgress ()

get current transcoding files progress

public void release ()

public void setAudioBitrate (int bitrate)

Set compose audio bitrate in bps.
do not set during merging default value : 48 * 1000

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.

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.

public void setAudioSampleRate (int sampleRate)

Set audio sample rate while streaming.
default value 44100

Parameters
sampleRate sample rate in Hz.

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.
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 setOnErrorListener (KSYMergeKit.OnErrorListener onErrorListener)

public void setOnInfoListener (KSYMergeKit.OnInfoListener onInfoListener)

public void setScaleMode (int scaleMode)

public void setTargetResolution (int width, int height)

Set transcode target size.

Parameters
width streaming width.
height streaming height.

public void setToTranscodeFiles (Map<String, Boolean> toTranscodeFiles)

public void setVideoBitrate (int bitrate)

Set merge video bitrate in bps
do not set during merging default value : 600 * 1000

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 transcoding.

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

public void setVideoFps (float fps)

Sets video fps.

Parameters
fps the fps

public void setVideoKBitrate (int kBitrate)

Set video bitrate in kbps

Parameters
kBitrate video bitrate in kbps

public void setVideoProfile (int videoProfile)

Set encode profile to video encoder.

Only valid in ENCODE_METHOD_SOFTWARE and ENCODE_METHOD_SOFTWARE_COMPAT mode.

Parameters
videoProfile 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 start (List<String> srcFiles, String outputFile, String transCodeTmpDir, boolean autoDeleteTmpDir)

start transcode and merge

Parameters
srcFiles source file url
outputFile dest file url
transCodeTmpDir temporary file directory for transcode
autoDeleteTmpDir flag of auto delete transcoded temporary files

public void stop ()

stop transcode and merge