Android

最近更新时间:2025-12-23 16:43:42

我的收藏

功能概览

滤镜可以对视频画面进行风格色彩的改变,本文将介绍滤镜的添加等使用方法。

相关接口类

接口类名
描述
TAVEditor
SDK 操作入口类。

接口方法汇总

方法
参数
说明
addFilter(String lutPath, float strength, long startPts, long endPts)
lutPath:滤镜素材路径。
strength:滤镜强度(0-1)。
startPts:开始时间(微秒)。
endPts:结束时间(微秒)。
添加滤镜并返回唯一 ID。
setFilterStrength(int filterId, float strength)
filterId:滤镜 ID。
strength:滤镜强度(0-1)。
调整滤镜强度。
removeFilter(int filterId)
filterId:滤镜 ID。
删除滤镜。

滤镜相关方法

添加滤镜

/**
* 添加滤镜
*
* @param lutPath 滤镜素材路径
* @param strength 滤镜强度(0-1)
* @param startPts 开始时间(微秒)
* @param endPts 结束时间(微秒)
* @return 滤镜唯一ID
*/
int filterId = editor.addFilter(lutPath, strength, startPts, endPts);

调整滤镜强度

/**
* 调整滤镜强度
*
* @param filterId 滤镜ID
* @param strength 滤镜强度(0-1)
*/
editor.setFilterStrength(filterId, strength);

删除滤镜

/**
* 删除滤镜
*
* @param filterId 滤镜ID
*/
editor.removeFilter(filterId);

使用示例

// 添加滤镜(强度0.8,从1秒到5秒)
int filterId = editor.addFilter("/sdcard/filter.lut", 0.8f, 1_000_000, 5_000_000);

// 调整滤镜强度到0.5
editor.setFilterStrength(filterId, 0.5f);

// 删除滤镜
editor.removeFilter(filterId);