public abstract class

EditBase

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

Class Overview

edit preview base

Summary

Nested Classes
interface EditBase.OnErrorListener  
interface EditBase.OnInfoListener  
class EditBase.TimeEffectParams  
Constants
float DEFAULT_SCALE
int SCALE_TYPE_1_1
int SCALE_TYPE_3_4
int SCALE_TYPE_9_16
int TIME_EFFECT_NONE
int TIME_EFFECT_REPEAT
int TIME_EFFECT_REVERSE
int TIME_EFFECT_SLOW
Fields
public static final int SCALING_MODE_BEST_FIT
public static final int SCALING_MODE_CROP
public static final int SCALING_MODE_FULL_FILL
protected static float SPEED_MAX_VALUE
protected static float SPEED_MIN_VALUE
protected AudioFilterMgt mAudioFilterMgt
protected AudioMixer mAudioMixer
protected AudioPlayerCapture mAudioPlayerCapture
protected KSYComposeKit mComposeKit
protected String mComposeTmpUrl
protected String mComposeUrl
protected Context mContext
protected boolean mDelayedStartEditPreview
protected long mEditDuration
protected String mEditUri
protected GLRender mGLRender
protected ImgTexFilterMgt mImgTexFilterMgt
protected ImgTexMixer mImgTexPreviewMixer
protected ImgTexScaleFilter mImgTexScaleFilter
protected Handler mMainHandler
protected KSYMergeKit mMergeKit
protected float mOriginAudioVolume
protected boolean mPlayPaused
protected KSYStickerView mStickerView
protected int mTimeEffectPreviewKey
protected int mTimeEffectType
protected List<TimerEffectFrame> mTimerEffectFrames
protected int mVideoHeight
protected int mVideoWidth
protected WaterMarkCapture mWaterMarkCapture
Public Constructors
EditBase(Context context)
Public Methods
void addPaintView(View view)
add paint view
void addStickerView(KSYStickerView view)
add static sticker view for preview and add/remove stickers
int addTimerEffectFilter(TimerEffectInfo effectInfo)
add timer effect for filter
void enableOriginAudio(boolean enable)
enable origin audio
AudioFilterMgt getAudioFilterMgt()
Get AudioFilterMgt instance to manage audio filters.
AudioPlayerCapture getAudioPlayerCapture()
Get AudioPlayerCapture instance which could handle BGM related operations.
float getBgmVolume()
get bgm volume
float getCropScale()
the max size for@return
abstract long getCurrentPosition()
long getEditDuration()
return valid value after SHORTVIDEO_EDIT_PREPARED
String getEditUrl()
get edit url
GLRender getGLRender()
Get GLRender instance.
ImgTexFilterMgt getImgTexFilterMgt()
Get ImgTexFilterMgt instance to manage GPU filters.
ImgTexMixer getImgTexPreviewMixer()
Get ImgTexMixer instance which could handle PIP related operations for preview.
boolean getIsLandscape()
return src video landscape info
float getMAXSpeed()
return the max speed for preview
float getMINSpeed()
return the min speed for preview
abstract MediaCapture getMediaCapture()
KSYMediaPlayer getMediaPlayer()
float getNomalSpeed()
return the nomal speed for preview
float getOriginAudioVolume()
get mic volume
abstract PlayRanges getPlayableRanges()
RectF getPreviewCropRect()
return crop info for preview
int getProgress()
return compose progress
boolean getReversePlay()
int getTimeEffectCount()
return timer effect count
TimerEffectInfo getTimerEffectInfo(int id)
return timer effect depend id
static String getVersion()
Get current sdk version.
abstract String getVideoCodecMeta()
int getVideoEncodeMethod()
Get video encode method.
Bitmap getVideoThumbnailAtTime(long seekTime, int width, int height, boolean accurate)
get thumbnail on time
void hideWaterMarkLogo()
Hide watermark logo.
abstract boolean isPaused()
void onPause()
pause edit preview Should be called on Activity.onPause or Fragment.onPause.
void onResume()
pause edit preview Should be called on Activity.onResume or Fragment.onResume.
void pauseEditPreview()
pause all edit preview included bgm play
abstract void pausePlay(boolean pause)
abstract void queueLastFrame()
void release()
Release all resources used by KSYEditKit.
void removeAllTimeEffectFilter()
remove all effect filter
void removeTimerEffectFilter(int index)
移除特效滤镜
void resumeEditPreview()
resume all edit preview included bgm play
void seekBGM(long seekto)
seek bgm to target time
abstract void seekTo(long position)
void setAudioBitrate(int bitrate)
Set compose audio bitrate in bps.
void setAudioEncodeMethod(int encodeMethod)
Set compose encode method for audio.
void setAudioEncodeProfile(int profile)
Set audio encode profile.
void setAudioKBitrate(int kBitrate)
Set compose audio bitrate in kbps.
void setAuidoDecodeMethod(int decodeMethod)
Set compose decode method for audio.
void setBGMRanges(long startTime, long endTime, boolean immediately)
set bgm playable ranges
void setBgmVolume(float volume)
set bgm volume
void setDecodeMethod(int decodeMethod)
Set compose decode method for both video and audio.
void setDecoderMethod(int decodeMethod)
Set compose decode method for video and audio.
void setEditPreviewRanges(long startTime, long endTime, boolean immediately)
set preview interval
void setEditPreviewUrl(String url)
Set edit url.
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 compose encode method for both video and audio.
void setForceVideoFrameFirst(boolean videoFirst)
force first frame to be video, must be called before startCompose
void setIFrameInterval(float interval)
set I frame interval
abstract void setLooping(boolean loop)
void setOnErrorListener(EditBase.OnErrorListener onErrorListener)
Set error listener.
void setOnInfoListener(EditBase.OnInfoListener onInfoListener)
Set info listener.
void setOriginAudioVolume(float volume)
Set mic volume.
void setOriginAudioVolume(float leftVolume, float rightVolume)
abstract void setPlayableRanges(long startTime, long endTime)
void setPreviewCrop(float left, float top, float w, float h)
crop preview
void setRotateDegrees(int degrees)
Set rotate degrees in anti-clockwise of current video.
void setScale(float scale)
任意比例裁剪模式
void setScaleType(int type)
set crop type
void setScalingMode(int mode)
set crop mode
void setTailUrl(String tailUrl)
set tail url
void setTargetResolution(int idx)
Set compose target resolution index.
void setTargetResolution(int width, int height)
Set compose target resolution.
void setTimerEffectOverlying(boolean overlying)
特效滤镜是否重叠,最好在添加第一个特效滤镜前设置,不建议动态设置
void setTitleUrl(String titleUrl)
set title url
void setVideoBitrate(int bitrate)
Set compose video bitrate in bps
Would take effect on next startCompose(String) ()} call.
void setVideoCodecId(int codecId)
Set compose codec id to video encoder.
void setVideoCrf(int crf)
set Constant Rate Factor do not effect on StreamerConstants#ENCODE_METHOD_HARDWARE valid value: 0~51 default value: 24
void setVideoDecodeMethod(int decodeMethod)
Set compose decode method for video.
void setVideoEncodeMethod(int encodeMethod)
Set compose encode method for video.
void setVideoEncodeProfile(int profile)
Set encode profile to video encoder.
void setVideoFps(float fps)
set compose video fps.
void setVideoKBitrate(int kBitrate)
Set compose video bitrate in kbps
Would take effect on next startCompose(String) ()} call.
void showWaterMarkLogo(String path, float x, float y, float w, float h, float alpha)
Set and show watermark logo both on preview and compose.
boolean startBgm(String path, boolean loop)
Start bgm play.
void startCompose(String desUrl)
start compose
void startEditPreview()
start edit preview must setEditPreviewUrl(String) before call
void stopBgm()
Stop bgm play.
void stopCompose()
stop compose
void stopEditPreview()
stop edit preview
void updateSpeed(boolean plus)
update speed of preview
void updateStickerDraw()
update sticker draw 立即生效当前预览时间点的贴纸绘制状态时调用,例如:暂停状态时seek后
void updateTimerEffectEndTime(int id, long endTime)
更新滤镜的结束事件
Protected Methods
long checkAndGetSeekPosition(long position)
检查position,不能超过裁剪区间
void doPrepared(long duration, int width, int height, int degree)
void doStopped()
abstract int getWorkMode()
void initModules()
void postError(int type, long msg)
void postInfo(int type, String msg)
abstract void restartPreview()
abstract void startPreview()
abstract void stopPreview()
void updateFilterEffect()
void updateSticker(long pts)
合成时更新贴纸显示
void updateStickerDraw(long currentPosition)
预览更新贴纸显示
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final float DEFAULT_SCALE

Constant Value: 0.5625

public static final int SCALE_TYPE_1_1

Constant Value: 3 (0x00000003)

public static final int SCALE_TYPE_3_4

Constant Value: 2 (0x00000002)

public static final int SCALE_TYPE_9_16

Constant Value: 1 (0x00000001)

public static final int TIME_EFFECT_NONE

Constant Value: 0 (0x00000000)

public static final int TIME_EFFECT_REPEAT

Constant Value: 2 (0x00000002)

public static final int TIME_EFFECT_REVERSE

Constant Value: 1 (0x00000001)

public static final int TIME_EFFECT_SLOW

Constant Value: 3 (0x00000003)

Fields

public static final int SCALING_MODE_BEST_FIT

public static final int SCALING_MODE_CROP

public static final int SCALING_MODE_FULL_FILL

protected static float SPEED_MAX_VALUE

protected static float SPEED_MIN_VALUE

protected AudioFilterMgt mAudioFilterMgt

protected AudioMixer mAudioMixer

protected AudioPlayerCapture mAudioPlayerCapture

protected KSYComposeKit mComposeKit

protected String mComposeTmpUrl

protected String mComposeUrl

protected Context mContext

protected boolean mDelayedStartEditPreview

protected long mEditDuration

protected String mEditUri

protected GLRender mGLRender

protected ImgTexFilterMgt mImgTexFilterMgt

protected ImgTexMixer mImgTexPreviewMixer

protected ImgTexScaleFilter mImgTexScaleFilter

protected Handler mMainHandler

protected KSYMergeKit mMergeKit

protected float mOriginAudioVolume

protected boolean mPlayPaused

protected KSYStickerView mStickerView

protected int mTimeEffectPreviewKey

protected int mTimeEffectType

protected List<TimerEffectFrame> mTimerEffectFrames

protected int mVideoHeight

protected int mVideoWidth

protected WaterMarkCapture mWaterMarkCapture

Public Constructors

public EditBase (Context context)

Public Methods

public void addPaintView (View view)

add paint view

public void addStickerView (KSYStickerView view)

add static sticker view for preview and add/remove stickers

public int addTimerEffectFilter (TimerEffectInfo effectInfo)

add timer effect for filter

public void enableOriginAudio (boolean enable)

enable origin audio

public AudioFilterMgt getAudioFilterMgt ()

Get AudioFilterMgt instance to manage audio filters.

Returns
  • AudioFilterMgt instance

public AudioPlayerCapture getAudioPlayerCapture ()

Get AudioPlayerCapture instance which could handle BGM related operations.

Returns
  • AudioPlayerCapture instance

public float getBgmVolume ()

get bgm volume

Returns
  • volume in 0~2.0f.

public float getCropScale ()

the max size for@return

public abstract long getCurrentPosition ()

public long getEditDuration ()

return valid value after SHORTVIDEO_EDIT_PREPARED

Returns
  • the origin media duration

public String getEditUrl ()

get edit url

Returns
  • edit url

public GLRender getGLRender ()

Get GLRender instance.

Returns
  • GLRender instance.

public ImgTexFilterMgt getImgTexFilterMgt ()

Get ImgTexFilterMgt instance to manage GPU filters.

Returns
  • ImgTexFilterMgt instance.

public ImgTexMixer getImgTexPreviewMixer ()

Get ImgTexMixer instance which could handle PIP related operations for preview.

Returns
  • ImgTexMixer instance.

public boolean getIsLandscape ()

return src video landscape info

public float getMAXSpeed ()

return the max speed for preview

public float getMINSpeed ()

return the min speed for preview

public abstract MediaCapture getMediaCapture ()

public KSYMediaPlayer getMediaPlayer ()

public float getNomalSpeed ()

return the nomal speed for preview

public float getOriginAudioVolume ()

get mic volume

Returns
  • volume in 0~2.0f.

public abstract PlayRanges getPlayableRanges ()

public RectF getPreviewCropRect ()

return crop info for preview

public int getProgress ()

return compose progress

public boolean getReversePlay ()

public int getTimeEffectCount ()

return timer effect count

public TimerEffectInfo getTimerEffectInfo (int id)

return timer effect depend id

public static String getVersion ()

Get current sdk version.

Returns
  • version number as 1.0.0.0

public abstract String getVideoCodecMeta ()

public int getVideoEncodeMethod ()

Get video encode method.

Returns
  • video encode method.
See Also
  • StreamerConstants#ENCODE_METHOD_SOFTWARE
  • StreamerConstants#ENCODE_METHOD_SOFTWARE_COMPAT
  • StreamerConstants#ENCODE_METHOD_HARDWARE

public Bitmap getVideoThumbnailAtTime (long seekTime, int width, int height, boolean accurate)

get thumbnail on time

public void hideWaterMarkLogo ()

Hide watermark logo.

public abstract boolean isPaused ()

public void onPause ()

pause edit preview Should be called on Activity.onPause or Fragment.onPause.

public void onResume ()

pause edit preview Should be called on Activity.onResume or Fragment.onResume.

public void pauseEditPreview ()

pause all edit preview included bgm play

public abstract void pausePlay (boolean pause)

public abstract void queueLastFrame ()

public void release ()

Release all resources used by KSYEditKit.

public void removeAllTimeEffectFilter ()

remove all effect filter

public void removeTimerEffectFilter (int index)

移除特效滤镜

Parameters
index 移除滤镜的唯一标识,在addTimerEffectFilter产生

public void resumeEditPreview ()

resume all edit preview included bgm play

public void seekBGM (long seekto)

seek bgm to target time

public abstract void seekTo (long position)

public void setAudioBitrate (int bitrate)

Set compose audio bitrate in bps.
Would take effect on next startCompose(String) ()} call. default value : 48 * 1000

Parameters
bitrate audio bitrate in bps.
Throws
IllegalArgumentException

public void setAudioEncodeMethod (int encodeMethod)

Set compose encode method for audio.
Must not be set while encoding.

Parameters
encodeMethod Encode method.
Throws
IllegalStateException
IllegalArgumentException
IllegalStateException
See Also
  • StreamerConstants#ENCODE_METHOD_SOFTWARE
  • StreamerConstants#ENCODE_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 compose audio bitrate in kbps.
Would take effect on next startCompose(String) ()} call.

Parameters
kBitrate audio bitrate in kbps.
Throws
IllegalArgumentException

public void setAuidoDecodeMethod (int decodeMethod)

Set compose decode method for 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 setBGMRanges (long startTime, long endTime, boolean immediately)

set bgm playable ranges

Parameters
immediately 是否立即生效

public void setBgmVolume (float volume)

set bgm volume

Parameters
volume in 0~2.0f.

public void setDecodeMethod (int decodeMethod)

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

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

public void setDecoderMethod (int decodeMethod)

Set compose 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 setEditPreviewRanges (long startTime, long endTime, boolean immediately)

set preview interval

public void setEditPreviewUrl (String url)

Set edit url.
must set before startEditPreview, must not be null The set url would take effect on the next startEditPreview() call.

Parameters
url edit url to set.
Throws
IllegalArgumentException

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 compose 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_HARDWARE

public void setForceVideoFrameFirst (boolean videoFirst)

force first frame to be video, must be called before startCompose

Parameters
videoFirst video first or not

public void setIFrameInterval (float interval)

set I frame interval

Parameters
interval I frame interval

public abstract void setLooping (boolean loop)

public void setOnErrorListener (EditBase.OnErrorListener onErrorListener)

Set error listener.

Parameters
onErrorListener error listener

public void setOnInfoListener (EditBase.OnInfoListener onInfoListener)

Set info listener.

Parameters
onInfoListener info listener

public void setOriginAudioVolume (float volume)

Set mic volume.

Parameters
volume volume in 0~2.0f.

public void setOriginAudioVolume (float leftVolume, float rightVolume)

public abstract void setPlayableRanges (long startTime, long endTime)

public void setPreviewCrop (float left, float top, float w, float h)

crop preview

Parameters
left The percentage of the video clipping to the left
top The percentage of the video clipping to the top

public void setRotateDegrees (int degrees)

Set rotate degrees in anti-clockwise of current video.

Parameters
degrees Degrees in anti-clockwise, only 0, 90, 180, 270 accepted.
Throws
IllegalArgumentException

public void setScale (float scale)

任意比例裁剪模式

public void setScaleType (int type)

public void setScalingMode (int mode)

public void setTailUrl (String tailUrl)

set tail url

public void setTargetResolution (int idx)

Set compose target resolution index.

The set resolution would take effect immediately if compose started.

Parameters
idx Resolution index.
Throws
IllegalArgumentException
IllegalArgumentException
IllegalStateException
See Also
  • StreamerConstants#VIDEO_RESOLUTION_360P
  • StreamerConstants#VIDEO_RESOLUTION_480P
  • StreamerConstants#VIDEO_RESOLUTION_540P
  • StreamerConstants#VIDEO_RESOLUTION_720P

public void setTargetResolution (int width, int height)

Set compose 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 setTimerEffectOverlying (boolean overlying)

特效滤镜是否重叠,最好在添加第一个特效滤镜前设置,不建议动态设置

Parameters
overlying default:true

public void setTitleUrl (String titleUrl)

set title url

public void setVideoBitrate (int bitrate)

Set compose video bitrate in bps
Would take effect on next startCompose(String) ()} call. default value : 600 * 1000

Parameters
bitrate video bitrate in bps
Throws
IllegalArgumentException

public void setVideoCodecId (int codecId)

Set compose codec id to video encoder.

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

public void setVideoCrf (int crf)

set Constant Rate Factor do not effect on StreamerConstants#ENCODE_METHOD_HARDWARE valid value: 0~51 default value: 24

public void setVideoDecodeMethod (int decodeMethod)

Set compose 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 compose 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_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)

set compose video fps.

Parameters
fps the fps
Throws
IllegalArgumentException

public void setVideoKBitrate (int kBitrate)

Set compose video bitrate in kbps
Would take effect on next startCompose(String) ()} call.

Parameters
kBitrate video bitrate in kbps
Throws
IllegalArgumentException

public void showWaterMarkLogo (String path, float x, float y, float w, float h, float alpha)

Set and show watermark logo both on preview and compose. Support jpeg, png.

Parameters
path logo file path. prefix "file://" for absolute path, and prefix "assets://" for image resource in assets folder.
x x position for left top of logo relative to the video, between 0~1.0.
y y position for left top of logo relative to the video, between 0~1.0.
w width of logo relative to the video, between 0~1.0, if set to 0, width would be calculated by h and logo image radio.
h height of logo relative to the video, between 0~1.0, if set to 0, height would be calculated by w and logo image radio.
alpha alpha value, between 0~1.0

public boolean startBgm (String path, boolean loop)

Start bgm play.

Parameters
path bgm path.
loop true if loop this music, false if not.

public void startCompose (String desUrl)

start compose

Parameters
desUrl the path for the compose file

public void startEditPreview ()

start edit preview must setEditPreviewUrl(String) before call

Throws
IllegalArgumentException

public void stopBgm ()

Stop bgm play.

public void stopCompose ()

stop compose

public void stopEditPreview ()

stop edit preview

public void updateSpeed (boolean plus)

update speed of preview

Parameters
plus true: up; false: down; unit:0.1;

public void updateStickerDraw ()

update sticker draw 立即生效当前预览时间点的贴纸绘制状态时调用,例如:暂停状态时seek后

public void updateTimerEffectEndTime (int id, long endTime)

更新滤镜的结束事件

Parameters
id 待更新滤镜的唯一标识,在addTimerEffectFilter时产生
endTime 更新后的结束时间

Protected Methods

protected long checkAndGetSeekPosition (long position)

检查position,不能超过裁剪区间

protected void doPrepared (long duration, int width, int height, int degree)

protected void doStopped ()

protected abstract int getWorkMode ()

protected void initModules ()

protected void postError (int type, long msg)

protected void postInfo (int type, String msg)

protected abstract void restartPreview ()

protected abstract void startPreview ()

protected abstract void stopPreview ()

protected void updateFilterEffect ()

protected void updateSticker (long pts)

合成时更新贴纸显示

protected void updateStickerDraw (long currentPosition)

预览更新贴纸显示