java.lang.Object | |
↳ | com.ksyun.media.shortvideo.kit.EditBase |
![]() |
edit preview base
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
add paint view
add static sticker view for preview and add/remove stickers
enable origin audio
Get AudioFilterMgt instance to manage audio filters.
Get AudioPlayerCapture
instance which could handle BGM related operations.
get bgm volume
return valid value after SHORTVIDEO_EDIT_PREPARED
get edit url
Get ImgTexFilterMgt instance to manage GPU filters.
Get ImgTexMixer instance which could handle PIP related operations for preview.
return src video landscape info
return the max speed for preview
return the min speed for preview
return the nomal speed for preview
get mic volume
return crop info for preview
return compose progress
return timer effect count
Get current sdk version.
Get video encode method.
get thumbnail on time
Hide watermark logo.
pause edit preview Should be called on Activity.onPause or Fragment.onPause.
pause edit preview Should be called on Activity.onResume or Fragment.onResume.
pause all edit preview included bgm play
Release all resources used by KSYEditKit.
remove all effect filter
移除特效滤镜
index | 移除滤镜的唯一标识,在addTimerEffectFilter产生 |
---|
resume all edit preview included bgm play
seek bgm to target time
Set compose audio bitrate in bps.
Would take effect on next startCompose(String)
()} call.
default value : 48 * 1000
bitrate | audio bitrate in bps. |
---|
IllegalArgumentException |
---|
Set compose encode method for audio.
Must not be set while encoding.
encodeMethod | Encode method. |
---|
IllegalStateException | |
IllegalArgumentException | |
IllegalStateException |
Set audio encode profile.
profile | profile to set. |
---|
Set compose audio bitrate in kbps.
Would take effect on next startCompose(String)
()} call.
kBitrate | audio bitrate in kbps. |
---|
IllegalArgumentException |
---|
Set compose decode method for audio.
Must not be set while decoding.
decodeMethod | Decode method. |
---|
IllegalStateException | |
IllegalArgumentException | |
IllegalStateException |
set bgm playable ranges
immediately | 是否立即生效 |
---|
set bgm volume
volume | in 0~2.0f. |
---|
Set compose decode method for both video and audio.
Must not be set while encoding.
default value:ENCODE_METHOD_SOFTWARE
decodeMethod | Decode method. |
---|
IllegalStateException | |
IllegalArgumentException | |
IllegalStateException |
Set compose decode method for video and audio.
Must not be set while decoding.
decodeMethod | Decode method. |
---|
IllegalStateException | |
IllegalArgumentException | |
IllegalStateException |
set preview interval
Set edit url.
must set before startEditPreview, must not be null
The set url would take effect on the next startEditPreview()
call.
url | edit url to set. |
---|
IllegalArgumentException |
---|
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.
enable | true to enable, false to disable |
---|
Set compose encode method for both video and audio.
Must not be set while encoding.
default value:ENCODE_METHOD_SOFTWARE
encodeMethod | Encode method. |
---|
IllegalStateException | |
IllegalArgumentException | |
IllegalStateException |
force first frame to be video, must be called before startCompose
videoFirst | video first or not |
---|
set I frame interval
interval | I frame interval |
---|
Set error listener.
onErrorListener | error listener |
---|
Set info listener.
onInfoListener | info listener |
---|
Set mic volume.
volume | volume in 0~2.0f. |
---|
crop preview
left | The percentage of the video clipping to the left |
---|---|
top | The percentage of the video clipping to the top |
Set rotate degrees in anti-clockwise of current video.
degrees | Degrees in anti-clockwise, only 0, 90, 180, 270 accepted. |
---|
IllegalArgumentException |
---|
任意比例裁剪模式
set crop type
set tail url
Set compose target resolution index.
The set resolution would take effect immediately if compose started.
idx | Resolution index. |
---|
IllegalArgumentException | |
IllegalArgumentException | |
IllegalStateException |
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.
width | streaming width. |
---|---|
height | streaming height. |
IllegalArgumentException |
---|
特效滤镜是否重叠,最好在添加第一个特效滤镜前设置,不建议动态设置
overlying | default:true |
---|
set title url
Set compose video bitrate in bps
Would take effect on next startCompose(String)
()} call.
default value : 600 * 1000
bitrate | video bitrate in bps |
---|
IllegalArgumentException |
---|
Set compose codec id to video encoder.
codecId | video codec id to set. |
---|
IllegalArgumentException |
---|
set Constant Rate Factor do not effect on StreamerConstants#ENCODE_METHOD_HARDWARE valid value: 0~51 default value: 24
Set compose decode method for video.
Must not be set while decoding.
decodeMethod | Decode method. |
---|
IllegalStateException | |
IllegalArgumentException | |
IllegalStateException |
Set compose encode method for video.
Must not be set while encoding.
encodeMethod | Encode method. |
---|
IllegalStateException | |
IllegalArgumentException | |
IllegalStateException |
Set encode profile to video encoder.
Only valid in ENCODE_METHOD_SOFTWARE and ENCODE_METHOD_SOFTWARE_COMPAT mode.
profile | encode profile mode to be set, default value VideoEncodeFormat#ENCODE_PROFILE_LOW_POWER |
---|
set compose video fps.
fps | the fps |
---|
IllegalArgumentException |
---|
Set compose video bitrate in kbps
Would take effect on next startCompose(String)
()} call.
kBitrate | video bitrate in kbps |
---|
IllegalArgumentException |
---|
Set and show watermark logo both on preview and compose. Support jpeg, png.
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 |
Start bgm play.
path | bgm path. |
---|---|
loop | true if loop this music, false if not. |
start compose
desUrl | the path for the compose file |
---|
start edit preview
must setEditPreviewUrl(String)
before call
IllegalArgumentException |
---|
Stop bgm play.
stop compose
stop edit preview
update speed of preview
plus | true: up; false: down; unit:0.1; |
---|
update sticker draw 立即生效当前预览时间点的贴纸绘制状态时调用,例如:暂停状态时seek后
更新滤镜的结束事件
id | 待更新滤镜的唯一标识,在addTimerEffectFilter时产生 |
---|---|
endTime | 更新后的结束时间 |
检查position,不能超过裁剪区间
合成时更新贴纸显示
预览更新贴纸显示