API | Description |
Initialize the SDK. Two forms are supported: 1. initSDK(Context context, String resPath) Uses static libraries and specifies the light_assets directory.2. initSDK(Context context, String resPath, String libsPath) Supports a custom dynamic library directory. | |
Copy AI model files: Copies the downloaded AI model files from srcPath to resDir the resource directory corresponding to . Returns 0 on success, -1 if srcPath does not exist, and -2 if an I/O error occurs. | |
Copy the AI model files under assets to the specified local path path, which must be consistent with the path passed to initSDK. Returns 0 on success, -1 if context is null, and -2 if an I/O error occurs. | |
Get the global Application Context saved when the SDK is initialized. | |
Get the current SDK version number in the format: VERSION_NAME.VERSION_CODE. | |
Get the currently used Light Assets root directory path. | |
Set the thumbnail file cache directory root path. | |
Sets the memory cache size for thumbnails. | |
Set the maximum disk cache size for thumbnails. | |
Sets the number of threads used by thumbnail software decoding. | |
Set SDK log level. setLogLevel(int level)Only set the log level;setLogLevel(int level, ITELogger logger)Also set the log level and access a custom log callback. |
public static boolean initSDK(Context context, String resPath)Parameter | Type | Description |
context | Context | Android context object, used internally getApplicationContext()save global references. |
resPath | String | Light Assets root directory path for installation light_assetsresource. |
boolean true, returns if SO or resource fails to loadfalse.public static boolean initSDK(Context context, String resPath, String libsPath)Parameter | Type | Description |
context | Context | Android context object, used internally getApplicationContext()Save global references. |
resPath | String | Light Assets root directory path for installation light_assetsresource. |
libsPath | String | Customize the dynamic library directory path for loading TAV related SO files. |
boolean true, returns if SO or resource fails to loadfalse.public static int installAIModelFile(String srcPath, String resDir)Parameter | Type | Description |
srcPath | String | The path to the source directory where the AI model file is stored (the directory where the downloaded model file is located). |
resDir | String | The root directory used to store beauty resources. This directory is created with XmagicApiThe path passed in is consistent with the object. |
int 0: Copy successful.-1:srcPathdoesn't exist.-2:IO error.assetsCopy the AI model files in the directory to the local specified path.public static int installAIModelFilesFromAssets(Context context, String path)Parameter | Type | Description |
context | Context | Android context object, needed when copying assets resources. |
path | String | The target path of the copied resource needs to be matched with initSDKThe incoming Light Assets path remains consistent. |
int 0: Copy successfully.-1:contextis null.-2:IO error.initSDK the Application Context saved at the time is used for global reuse within the SDK to avoid leaking components such as Activity / Service.public static Context getApplicationContext()Context Context; if not initialized, it may benull please make sure you have executed it before callinginitSDK.public static String getSDKVersion()String "{VERSION_NAME}.{VERSION_CODE}"version string, for example:1.2.3.45.public static String getLightAssetsDir()String initSDK incoming and through TAVResourceUtil.fixPathSuffix the processed Light Assets root directory; if not initialized, it may benull.initSDKInternally it will be set by default tocontext.getCacheDir()/thumbnails, if the business needs to customize the directory, this method can be called again to overwrite it.public static void setThumbnailCacheDir(String cacheDirPath)Parameter | Type | Description |
cacheDirPath | String | Path (folder) to the thumbnail disk cache directory. |
void TAVFrameExtractorConfigImplementation), used to control thumbnail memory usage.public static void setThumbnailMemoryCacheSize(int cacheSize)Parameter | Type | Description |
cacheSize | int | Memory cache size configuration value. |
void public static void setThumbnailCacheCapacity(long capacity)Parameter | Type | Description |
capacity | long | Maximum disk cache capacity (unit: bytes). |
void public static void setThumbnailThreadCount(int count)Parameter | Type | Description |
count | int | Number of threads (Integer >0). |
void setLogLevel(level, null), only controls the internal unified log level and does not connect to custom log callbacks.public static void setLogLevel(int level)Parameter | Type | Description |
level | int | Log level, recommended Log.VERBOSE / Log.DEBUG / Log.INFO / Log.WARN / Log.ERROR / TAVMagicBase.NO_LOG. |
void ITELogger.public static void setLogLevel(int level, ITELogger logger)Parameter | Type | Description |
level | int | Log level, recommended Log.VERBOSE / Log.DEBUG / Log.INFO / Log.WARN / Log.ERROR / TAVMagicBase.NO_LOG. |
logger | ITELogger | Custom log callback interface implementation; pass in nullThen it will only be output through the internal TELog and will no longer be called back to the business layer. |
void API | Description |
Initialize the editor and pass in preview parameters (parent container and rendering method, etc.). | |
Destroy the editor and release internal resources. | |
Set the template directory path and return the template loading result code. 0:SUCCESS -1:PATH_INVALID -2:AUTH_INVALID | |
Get the absolute path of the current template directory. | |
Obtain the pit configuration information of the specified template path (template placeholder, copywriting, material requirements, etc.). | |
Copy and create a new editing instance from the current editing object. You can create on-screen/off-screen instances based on preview parameters and decide whether to create a rendering chain. | |
Read a snapshot of the current rendering screen, and the result is returned asynchronously through the callback. | |
Gets the rendering size used by the current preview. | |
Gets the rendering size used for exporting videos based on the export quality level. | |
Set the canvas width and height ratio (save as ratio, not directly as final pixel width and height). | |
Adding video resources: Supports appending at the end or inserting a video list at a specified position, and returns the index after successful addition. | |
Adding picture resources: Supports appending at the end or inserting a picture list at a specified position. You can specify the playback duration and return the index after successful addition. | |
Get the total number of resources (videos/images) currently being edited. | |
Click the resource subscript to remove the corresponding video or image resource. | |
Set the playback time interval of the specified resource (startTimeUs ~ endTimeUs), and the video will be intercepted and played within this interval. | |
Set the volume of the specified video resource (0–1f). | |
Sets a uniform background volume (0–1f) for all input resources. | |
Get the current volume of the specified video resource. | |
Set the playback speed of the specified video resource. | |
Get the playback speed of the specified video resource. | |
Adjust the order of resources, move resources from the old subscript to the new subscript, and return whether the adjustment is successful. | |
Get the basic information corresponding to the input video path (duration, width, height, etc.). | |
Get the original video frame extraction interface, you can configure whether to force the use of soft decoding. | |
Add background music, specify the position inserted into the video timeline, material starting time and playback duration, and return a unique BGM ID. | |
Delete background music by BGM unique ID and return whether deletion is successful. | |
Adjust the starting position of background music on the video timeline. | |
Set the playback interval (start time and duration) of the specified background music within the material. | |
Sets the volume of the specified background music (recommended range 0–3f). | |
Sets a uniform volume for all background music (recommended range 0–3f). | |
Get the current volume of the specified background music. | |
Set the playback speed of the specified background music. 1 is normal Greater than 1 means it is faster Less than 1 means slowing down | |
Get the playback speed of the specified background music. | |
Set whether the player enables loop playback. | |
Set up a preview listener to receive callbacks such as playback progress, completion, and errors. | |
Start playing the preview. | |
Set the time interval for preview playback (start time and duration). | |
Resumes the preview after pausing. | |
Pause the current preview playback. | |
Get the total playing time of the current project (unit: us). | |
Determine whether it is currently playing. | |
Move the playback position to a specified time point, optionally non-precise seek (jump to adjacent keyframe). | |
Sets the clockwise rotation angle (0–360°) of the specified video resource. | |
Sets the cropping area of the specified video resource (RectF normalized relative to the rendering size). | |
Set a custom texture processing callback for secondary processing of the rendering texture. | |
Removed custom texture processing callbacks. | |
Add a filter effect, passing in the LUT path, intensity and time interval, and returning a unique filter ID. | |
Adjusts the strength of the specified filter (0–1f). | |
Delete the specified filter effect. | |
Get the sticker management interface for adding, editing and deleting stickers. | |
Get the Picture-in-Picture management interface for adding, editing and deleting Picture-in-Picture content. | |
Set the transition material at the specified location, configure the resource path and duration, and return the transition ID. | |
Updates the duration of the specified transition effect. | |
Delete the specified transition effect and return whether the deletion is successful. | |
Add animation, support basic version and version with scaleMode, return animation ID. | |
Adjust the playback time interval (start node and duration) of the specified animation. | |
Delete the specified animation. | |
Get the rendering result image at a certain point in time, scale it according to the long side and specify the rendering scene, and return it through the callback. | |
Get the frame to provide an interface to continuously generate rendering results based on the length of the long side and the rendering scene. | |
Export video: Supports exporting to a specified path according to preset export levels or custom encoding configurations, and obtains progress and results through the listener. | |
Cancel the video export task currently in progress. | |
Immediately refresh the current rendering, support calling without parameters or carrying tag and callback, and execute the callback after the refresh is completed. | |
Get the draft management interface for saving, restoring and managing edited drafts. |
void initWithPreview(TAVEditorConstants.PreviewParam param)Parameter | Type | Description |
param | Preview parameters (parent container, rendering method, etc.). |
void void release()void param.videoView = null:Create an off-screen instance.param.videoView != null:Create an instance on the screen.param = null: Create a default off-screen instance.param != null: According toparam.scene determines whether to create a render chain.TAVEditor fork(TAVEditorConstants.PreviewParam param)Parameter | Type | Description |
param | Preview configuration parameters for the new instance. |
TAVEditor void readSnapshot(TAVSnapshotCallback callback)Parameter | Type | Description |
callback | TAVSnapshotCallback | Called back when the snapshot is obtained successfully. |
void int setTemplateDir(String path)Parameter | Type | Description |
path | String | Template directory path. |
int TAVTemplateCode:0 means SUCCESS, -1 means PATH_INVALID, -2 means AUTH_INVALID.String getTemplateDir()String TAVTemplateConfig getTemplateConfig(String templatePath)Parameter | Type | Description |
templatePath | String | Template path. |
TAVTemplateConfig Size getRenderSize()Size VIDEO_LEVEL_360P = 0:360×640 VIDEO_LEVEL_480P = 1:640×480 VIDEO_LEVEL_540P = 2:960×540 VIDEO_LEVEL_720P = 3:1280×720 VIDEO_LEVEL_1080P = 4:1920×1080Size getGeneratingRenderSize(@TAVEditorConstants.GenerateLevel int level)Parameter | Type | Description |
level | int(@GenerateLevel) | Export quality level (resolution gear). |
Size void setRenderSizeRatio(int width, int height)Parameter | Type | Description |
width | int | Canvas proportional width. |
height | int | Canvas proportional height. |
void int addVideoClip(String path)Parameter | Type | Description |
path | String | Video file path. |
int int addVideoClip(int clipIndex, List<String> paths)Parameter | Type | Description |
clipIndex | int | The target index of the insertion position. |
paths | List<String> | List of video source paths to be edited. |
int duration <= 0The default duration is 3 seconds.int addImageClip(String path, long duration)Parameter | Type | Description |
path | String | Image source path. |
duration | long | Image display duration (unit: us, <=0, default 3s). |
int duration <= 0The default duration is 3 seconds.int addImageClip(int clipIndex, List<String> paths, long duration)Parameter | Type | Description |
clipIndex | int | The target index of the insertion position. |
paths | List<String> | Image source path list. |
duration | long | Display duration of each picture (unit: us, <=0, default 3s). |
int int getClipCount()int void removeClip(int clipIndex)Parameter | Type | Description |
clipIndex | int | The subscript needs to be removed. |
void startTimeUs and endTimeUs the playback interval used to intercept the video.void setClipRange(int clipIndex, long startTimeUs, long endTimeUs)Parameter | Type | Description |
clipIndex | int | Resource subscript. |
startTimeUs | long | Resource playback start time (us). |
endTimeUs | long | Resource playback end time (us). |
void void setVideoClipVolume(int clipIndex, float volume)Parameter | Type | Description |
clipIndex | int | Video resource subscript. |
volume | float | Volume, range 0–1f. |
void void setAllClipsVolume(float volume)Parameter | Type | Description |
volume | float | Volume, range 0–1f. |
void float getVideoClipVolume(int clipIndex)Parameter | Type | Description |
clipIndex | int | Video subscript. |
float void setVideoClipSpeed(int clipIndex, float speed)Parameter | Type | Description |
clipIndex | int | Video clip. |
speed | float | Playback speed multiple. |
void float getVideoClipSpeed(int clipIndex)Parameter | Type | Description |
clipIndex | int | Video clip. |
float boolean updateClipIndex(int oldClipIndex, int newClipIndex)Parameter | Type | Description |
oldClipIndex | int | Clip before adjustment. |
newClipIndex | int | Adjusted clip. |
boolean TAVVideoInfo getVideoInfo(String path)Parameter | Type | Description |
path | String | Video file path. |
TAVVideoInfo ITAVThumbProvider getThumbnailProvider(boolean forceUseSoftwareDecoding)Parameter | Type | Description |
forceUseSoftwareDecoding | boolean | Whether to force the use of soft decoding frame extraction. |
int addBgm(String path, long startAtVideoTimeUS, long startTimeUS, long duration)Parameter | Type | Description |
path | String | Background music material file path. |
startAtVideoTimeUS | long | The time position (us) at which the music was added to the video. |
startTimeUS | long | The starting playback time of the audio material itself (us). |
duration | long | Audio playback duration (us). |
int boolean removeBgm(int bgmID)Parameter | Type | Description |
bgmID | int | Unique ID generated when adding background music. |
boolean void updateBgmPlayOffset(int bgmID, long videoStartTime)Parameter | Type | Description |
bgmID | int | Background music unique ID. |
videoStartTime | long | Starting position in the video (us). |
void void updateBgmPlayRange(int bgmID, long startTime, long duration)Parameter | Type | Description |
bgmID | int | Background music unique ID. |
startTime | long | Background music start playing time (us). |
duration | long | Background music duration (us). |
void void setBgmVolume(int bgmID, float volume)Parameter | Type | Description |
bgmID | int | Background music unique ID. |
volume | float | Volume, recommended range 0–3f. |
void void setAllBgmVolume(float volume)Parameter | Type | Description |
volume | float | Volume, recommended range 0–3f. |
void float getBgmVolume(int bgmID)Parameter | Type | Description |
bgmID | int | Background music unique ID. |
float void setBgmSpeed(int bgmID, float speed)Parameter | Type | Description |
bgmID | int | Background music unique ID. |
speed | float | Playback speed multiple, 1 is normal, greater than 1 becomes faster, less than 1 becomes slower. |
void float getBgmSpeed(int bgmID)Parameter | Type | Description |
bgmID | int | Background music unique ID. |
float void setPlayerLoop(boolean loop)Parameter | Type | Description |
loop | boolean | Whether to loop playback. |
void void setVideoPreviewListener(TAVPreviewListener listener)Parameter | Type | Description |
listener | Preview playback listening callback. |
void void startPlay()void void setPlayTimeRange(long startTime, long duration)Parameter | Type | Description |
startTime | long | Playback start time (us). |
duration | long | Playback duration (us). |
void void resumePlay()void void pausePlay()void long getTotalDuration()long boolean isPlaying()boolean true indicates that it is playing,false indicates not played.void seekToTime(long timeUs, boolean isInAccurate)Parameter | Type | Description |
timeUs | long | Jump target time (us). |
isInAccurate | boolean | Whether to enable non-precision seek: true. Jump to adjacent keyframe, false Accurate to the specified location. |
void void setClipRotation(int clipIndex, @FloatRange(from = 0, to = 360f) float degrees)Parameter | Type | Description |
clipIndex | int | Video clip index. |
degrees | float | Rotation angle, range 0–360 (degrees). |
void rectF is the clipping rectangle normalized relative to the rendering size.void setClipRect(int clipIndex, RectF rectF)Parameter | Type | Description |
clipIndex | int | Video clip index. |
rectF | RectF | Cropping area rectangle normalized relative to render size. |
void void setCustomVideoProcessListener(TAVCustomProcessListener listener)Parameter | Type | Description |
listener | TAVCustomProcessListener | Custom texture processing callback. |
void void removeCustomVideoProcessListener()void int addFilter(String lutPath, float strength, long startPts, long endPts)Parameter | Type | Description |
lutPath | String | Filter material path (LUT file, etc.). |
strength | float | Filter strength (0–1f). |
startPts | long | Effective start time (us). |
endPts | long | Effective end time (us). |
int void setFilterStrength(int filterId, float strength)Parameter | Type | Description |
filterId | int | Filter unique ID. |
strength | float | Filter strength (0–1f). |
void void removeFilter(int filterId)Parameter | Type | Description |
filterId | int | Filter unique ID. |
void ITAVStickerManager getStickerManager()ITAVPipManager getPipManager()int setTransition(int clipIndex, String path, long durationUS)Parameter | Type | Description |
clipIndex | int | The position of the transition (the index between fragments). |
path | String | Transition resource path. |
durationUS | long | Transition duration (us). |
int void updateTransitionDuration(int transitionId, long durationUS)Parameter | Type | Description |
transitionId | int | Transition ID |
durationUS | long | New transition duration (us) |
void boolean removeTransition(int transitionId)Parameter | Type | Description |
transitionId | int | Transition ID |
boolean int addMotionEffect(String path, long startOffset, long duration)Parameter | Type | Description |
path | String | Motion effect material path |
startOffset | long | Effective start time offset (us) |
duration | long | Play time (us) |
int int addMotionEffect(String path, long startOffset, long duration, int scaleMode)Parameter | Type | Description |
path | String | Motion effect material path |
startOffset | long | Effective start time offset (us) |
duration | long | Play time (us) |
scaleMode | int | Zoom mode |
int void updateMotionEffectPlayRange(int motionId, long startOffset, long duration)Parameter | Type | Description |
motionId | int | Animation unique ID |
startOffset | long | Effective start time offset (us) |
duration | long | Play time (us) |
void void removeMotionEffect(int motionId)Parameter | Type | Description |
motionId | int | Animation unique ID |
void void getFrameAtTime(long positionUs, int longSideLength, int scene, TAVGetFrameListener listener)Parameter | Type | Description |
positionUs | long | Time point (us) |
longSideLength | int | Output the length of the longest side of the image, and internally calculate the other side proportionally. |
scene | int(@RenderScene) | Rendering the scene, reference TAVEditorConstants.SCENE_PLAY |
listener | TAVGetFrameListener | Get result callback |
void ITAVFrameProvider getFrameProvider(int longSideLength, @TAVEditorConstants.RenderScene int scene)Parameter | Type | Description |
longSideLength | int | The length of the long side of the output frame will be scaled to align with the long side according to the rendering ratio. |
scene | int(@RenderScene) | Rendering the scene, reference TAVEditorConstants.SCENE_PLAY |
ITAVFrameProvider(can be null)void generateVideo(int level, String outputPath, TAVEditorGenerateListener listener)Parameter | Type | Description |
level | int(@GenerateLevel) | Export quality level (360P/480P/540P/720P/1080P, etc.) |
outputPath | String | Export file path |
listener | Export process callbacks (progress, completion, errors, etc.) |
void void generateVideo(TAVEditorGenerateConfig config, String outputPath, TAVEditorGenerateListener listener)Parameter | Type | Description |
config | Export configuration, such as width/height/frameRate/videoBitRate/profile, etc. | |
outputPath | String | Export file path |
listener | Export process callback |
void void cancelGenerate()void void flushImmediately()void void flushImmediately(@Nullable String tag, @Nullable TAVConsumer<String> callback)Parameter | Type | Description |
tag | String (can be null) | Flag of the current refresh operation |
callback | TAVConsumer<String> (can be null) | The task to be executed by the callback after the refresh is completed, the parameter is tag |
void TAVDraftManager getDraftManager()TAVDraftManager API | Description |
Set the frame input source, the incoming video path and the longest side of the target frame size; if longSide < 16, then the frames are extracted according to the original resolution of the video. | |
Extract frames in batches according to time intervals, extract consecutive frames from the video according to a given interval (microseconds), and return the results through a callback. | |
Extract frames in batches based on a specified time point list, combined with granularity (seconds/frame) from ptsListExtract the frame at the corresponding position and return the result through the callback. | |
Obtain a single frame image at a specified time point (microseconds), extract the corresponding frame based on the granularity (seconds/frame), and return the result through a callback. | |
Gets the cached frames corresponding to the specified video, time point, size and granularity from the memory or disk cache, and may return null. | |
Cache the frame image corresponding to a certain point in time, the specified size and granularity to the memory/disk for subsequent fast reading. | |
Get the duration of the current video, in microseconds (us). | |
Request to stop the currently ongoing frame extraction task. | |
Release frame extraction related resources and clean up the internal state. |
longSide less thanMIN_LONG_SIDE, frames will be extracted according to the original resolution of the video.void setDataSource(String videoPath, int longSide)Parameter | Type | Description |
videoPath | String | Video file path |
longSide | int | The length of the longest side of the target frame size, if less than MIN_LONG_SIDE, then use the original resolution to extract the frame |
void void getFramesInterval(long intervalUs, FrameExtractingCallback callback)Parameter | Type | Description |
intervalUs | long | Frame extraction time interval (unit: microsecond) |
callback | FrameExtractingCallback | Frame extraction result callback interface |
void ptsList, and specify a "granularity" to control the frame interval accuracy.void getFrames(List<Long> ptsList, float granularity, FrameExtractingCallback callback)Parameter | Type | Description |
ptsList | List<Long> | List of time points at which frames need to be extracted (unit: microseconds) |
granularity | float | Granularity, which represents how many seconds a frame is, is used to control the accuracy/tolerance of frame extraction intervals. |
callback | FrameExtractingCallback | Frame extraction result callback interface |
void granularity controls frame interval precision, used to select appropriate keyframes around time.void getFrameAtTime(long pts, float granularity, FrameExtractingCallback callback)Parameter | Type | Description |
pts | long | Target frame extraction time point (unit: microsecond) |
granularity | float | Granularity, which represents how many seconds a frame is, is used to control the accuracy/tolerance of frame extraction intervals. |
callback | FrameExtractingCallback | Frame extraction result callback interface |
void null.Bitmap getCacheFrame(String path, long pts, int longSide, float granularity)Parameter | Type | Description |
path | String | Video path, consistent with the input path when extracting frames |
pts | long | Target time point (unit: microsecond) |
longSide | int | The long side of the frame extraction target, which is used when extracting frames. longSideconsistent |
granularity | float | Granularity, used when extracting frames granularityconsistent |
Bitmap null.getCacheFrameQuick reuse.void saveCacheFrame(String path, Bitmap bmp, long pts, int longSide, float granularity)Parameter | Type | Description |
path | String | Video path |
bmp | Bitmap | Frame images that need to be cached |
pts | long | The time point corresponding to this frame (unit: microsecond) |
longSide | int | Frame target long side size |
granularity | float | Frame extraction granularity is used to cache indexes to distinguish frame extraction results of different precisions. |
void long getDuration()long void requestStop()void void release()void API | Description |
Create a sticker object, specify the sticker type and sticker resource path, and return the newly created TAVSticker. | |
Load a sticker and instantly render it onto the screen. | |
Remove the specified sticker object, effective immediately. | |
Add a sticker observer to listen for events such as sticker list changes. | |
Removes the specified sticker observer. | |
Get a list of all stickers currently loaded. | |
Get the corresponding sticker object through the sticker ID, and return if it does not exist. null. | |
Register a guaranteed font. When PAG does not find a font, it will first fall back to the registered font list instead of the system font, and return whether the registration is successful. |
loadStickerIt will be displayed on the screen after use.TAVSticker createSticker(TAVSticker.TAVStickerType type, String stickerPath)Parameter | Type | Description |
type | TAVSticker.TAVStickerType | Sticker type |
stickerPath | String | Sticker resource path |
TAVSticker void loadSticker(TAVSticker sticker)Parameter | Type | Description |
sticker | TAVSticker | Sticker object to load |
void void removeSticker(TAVSticker sticker)Parameter | Type | Description |
sticker | TAVSticker | Sticker object to remove |
void void addStickerObserver(ITAVStickerContextObserver observer)Parameter | Type | Description |
observer | ITAVStickerContextObserver | Sticker list listener |
void void removeStickerObserver(ITAVStickerContextObserver observer)Parameter | Type | Description |
observer | ITAVStickerContextObserver | listener to remove |
void List<TAVSticker> getStickers()List<TAVSticker> TAVSticker getSticker(int id)Parameter | Type | Description |
id | int | Sticker ID |
TAVSticker null.boolean registerFallbackFont(String fontPath)Parameter | Type | Description |
fontPath | String | Font file path |
Returns | | |
boolean trueIndicates successful registration,falseIndicates a registration failure (e.g. invalid path or read failure).API | Description |
Create a Picture-in-Picture object, specify the media type and video/picture path, and return TAVPipExample. | |
Loads a Picture-in-Picture and instantly renders it onto the screen. | |
Removes the specified Picture-in-Picture object, effective immediately. | |
Add a Picture-in-Picture observer to monitor events such as changes in the Picture-in-Picture list. | |
Removes the specified Picture-in-Picture observer. | |
Get a list of all currently loaded Picture-in-Pictures. | |
Get the corresponding Picture-in-Picture object through the Picture-in-Picture ID, and return if it does not exist. null. |
TAVPip createPip(TAVMediaType type, String mediaPath)Parameter | Type | Description |
type | TAVMediaType | Resource type (video/image, etc.) |
mediaPath | String | Picture-in-Picture media resource path (video or image path) |
TAVPip createPip called after creating the Picture-in-Picture object.void loadPip(TAVPip pip)Parameter | Type | Description |
pip | TAVPip | The Picture-in-Picture object to load |
void void removePip(TAVPip pip)Parameter | Type | Description |
pip | TAVPip | Picture-in-Picture object to remove |
void void addPipObserver(ITAVPipContextObserver observer)Parameter | Type | Description |
observer | ITAVPipContextObserver | Picture-in-Picture list listener |
void addPipObserver use in pairs to avoid memory leaks.void removePipObserver(ITAVPipContextObserver observer)Parameter | Type | Description |
observer | ITAVPipContextObserver | listener to remove |
void List<TAVPip> getPips()List<TAVPip> TAVPip getPip(int id)Parameter | Type | Description |
id | int | Picture-in-Picture ID |
TAVPip null.API | Description |
Set the sticker progress processor, used for external custom sticker playback progress calculation, return the current TAVSticker supports chain calls. | |
Calculate the sticker playback progress (0~1) at the specified time point. Priority is given to using the externally registered progress processor, otherwise it is automatically calculated based on the time range and animation mode. | |
Set the sticker text content and add the new TAVStickerTextItem replace the original text layer content. | |
Get the sticker text content and return the current TAVStickerTextItem, if it does not exist, return null. | |
Set the sticker image content and add the new TAVStickerImageItem replace the original image layer content. | |
Get the sticker image content and return the current TAVStickerImageItem, if it does not exist, return null. | |
Get the sticker animation duration, in microseconds (us), internally based on PAGFile.duration(). | |
Get the width of the PAG resource corresponding to the sticker, in pixel units. | |
Get the height of the PAG resource corresponding to the sticker, in pixel units. | |
Gets the offset rectangular area of the text area relative to the entire sticker. It is only valid under text stickers (TEXT type). | |
Gets the offset rectangular area of the image relative to the entire sticker. It is only valid under image stickers (IMAGE type). | |
Get the sticker resource file path (local path or assets resource path). | |
Set whether stickers play automatically, true automatic loop playback,false do not play automatically, return to the current TAVSticker supports chain calls. | |
Get whether the current sticker has the auto-play flag turned on. | |
Get sticker types, such as animated stickers, text stickers, picture stickers, etc. | |
Set the sticker level, starting from 0. The larger the value, the higher the level. Returns the current TAVSticker supports chain calls. | |
Get the current level index of the sticker, starting from 0. The larger the value, the higher the level. | |
Get the sticker animation playback mode (loop, play until the last frame is still, stretch duration, etc.). | |
Set the sticker animation playback mode and synchronously update the TimeStretch mode of the internal PAG. | |
Gets whether the sticker is currently visible. | |
Set whether the sticker is visible and control whether the sticker is displayed in the rendering result. | |
Set the effective time interval of the sticker, synchronize the time range to the internal PAG layer, and return the current TAVSticker supports chain calls. | |
Set the position of the sticker in the canvas, support incoming PointF or x/y coordinate, returns the current TAVSticker supports chain calls. | |
Set the overall scaling of the sticker and return to the current TAVSticker supports chain calls. | |
Set the minimum zoom ratio allowed by the sticker and return the current TAVSticker supports chain calls. | |
Set the maximum zoom ratio allowed by the sticker and return the current TAVSticker supports chain calls. | |
Set the sticker rotation angle in degrees and return the current TAVSticker supports chain calls. | |
Set whether the sticker is editable (whether it responds to gestures and other interactions) and returns the current TAVSticker supports chain calls. | |
Clone the current sticker object, clone() it is the default shallow copy and is called internally.clone(boolean deep). | |
Clone the current sticker object, clone(boolean deep) you can control whether to make deep copies of text and picture layers. |
ITAVStickerProgressHandler.public TAVSticker setProgressHandler(ITAVStickerProgressHandler progressHandler)Parameter | Type | Description |
progressHandler | ITAVStickerProgressHandler | Custom sticker progress processor callback interface |
TAVSticker TAVSticker instance to facilitate chain calling.progressHandler, then call it firstcomputeProgress, otherwise according to the sticker duration, time range andanimationModeAutomatic calculation:FREEZEPlay to the last frame and then stop;SCALE_UPPlay at a slower speed if the user selects a duration greater than the original duration.public double computeProgress(long presentationTimeUs)Parameter | Type | Description |
presentationTimeUs | long | Current time point (unit: microsecond) |
double layerIndex only replace text content data.public void setTextItem(TAVStickerTextItem textItem)Parameter | Type | Description |
textItem | TAVStickerTextItem | text content object |
void null.public TAVStickerTextItem getTextItem()TAVStickerTextItem null.layerIndex, only replaces the image content data.public void setImageItem(TAVStickerImageItem imageItem)Parameter | Type | Description |
imageItem | TAVStickerImageItem | Image content object |
void null.public TAVStickerImageItem getImageItem()TAVStickerImageItem null.public long durationTime()long pagFile returns 0 if empty.public int getWidth()int pagFile returns 0 if empty.public int getHeight()int pagFile returns 0 if empty.TAVStickerType.TEXTvalid; other types returnnull.PAGPlayerTo avoid the situation where the visible area is 0.public RectF getTextOffsetRect()RectF null.TAVStickerType.IMAGE and when the picture is valid, a valid rectangle is returned.public RectF getImageOffsetRect()RectF null.public String getPath()String public TAVSticker setAutoPlay(boolean autoPlay)Parameter | Type | Description |
autoPlay | boolean | true indicates automatic playback,false indicates no automatic playback |
TAVSticker TAVSticker instance to facilitate chain calling.public boolean isAutoPlay()boolean true indicates automatic playback,false indicates no automatic playback.public TAVStickerType getType()TAVStickerType MOTION、TEXT、IMAGE.public TAVSticker setLayerIndex(int layerIndex)Parameter | Type | Description |
layerIndex | int | Sticker level index |
TAVSticker TAVSticker instance to facilitate chain calling.public int getLayerIndex()int public TAVStickerAnimationMode getAnimationMode()TAVStickerAnimationMode DEFAULT(cycle),FREEZE(Still after playing),SCALE_UP(slow playback).public void setAnimationMode(TAVStickerAnimationMode animationMode)Parameter | Type | Description |
animationMode | TAVStickerAnimationMode | Sticker animation playback mode |
void public boolean isVisible()boolean trueIndicates that the sticker is currently visible,falseIndicates invisible.public void setVisible(boolean visible)Parameter | Type | Description |
visible | boolean | Is it visible? trueto be visible |
void PAGFileon the layer.@Override public TAVSticker setTimeRange(TAVTimeRange timeRange)Parameter | Type | Description |
timeRange | TAVTimeRange | The time range of the sticker on the timeline |
TAVSticker TAVSticker instance to facilitate chain calling.@Override public TAVSticker setPosition(PointF point)Parameter | Type | Description |
point | PointF | Sticker center position coordinates |
TAVSticker TAVSticker instance to facilitate chain calling.@Override public TAVSticker setPosition(float x, float y)Parameter | Type | Description |
x | float | X coordinate |
y | float | Y coordinate |
TAVSticker TAVSticker instance to facilitate chain calling.@Override public TAVSticker setScale(float scale)Parameter | Type | Description |
scale | float | scaling factor |
TAVSticker TAVSticker instance to facilitate chain calling.@Override public TAVSticker setMinScale(float minScale)Parameter | Type | Description |
minScale | float | Minimum zoom ratio |
TAVSticker TAVSticker instance to facilitate chain calling.@Override public TAVSticker setMaxScale(float maxScale)Parameter | Type | Description |
maxScale | float | Maximum zoom ratio |
TAVSticker TAVSticker instance to facilitate chain calling.@Override public TAVSticker setRotate(float rotate)Parameter | Type | Description |
rotate | float | Rotation angle, unit: degrees |
TAVSticker TAVSticker instance to facilitate chain calling.@Override public TAVSticker setEditable(boolean editable)Parameter | Type | Description |
editable | boolean | Whether to allow editing |
TAVSticker TAVSticker instance to facilitate chain calling.TAVSticker instance.clone(false), that is, shallow copy text and image item references.@Override public TAVSticker clone()TAVSticker PAGFile content.deep == falsehour:textList、imageListThe reference is shared with the original object;deep == trueTime: Re-read the text and picture layers, and copy the data one by one to form an independent copy.public TAVSticker clone(boolean deep)Parameter | Type | Description |
deep | boolean | Whether to perform deep copy: truedeep copy,falseShallow copy |
TAVSticker API | Description |
Get the Picture-in-Picture resource file path. | |
Get the media type (video or picture) corresponding to Picture-in-Picture. | |
Get the current volume of Picture-in-Picture, the range is [0, 3]. | |
Set the Picture-in-Picture volume, the range is [0, 3]. | |
Get the current playback speed of Picture-in-Picture. | |
Set the Picture-in-Picture playback speed. | |
Gets the starting time of Picture-in-Picture on the main video timeline (unit: microseconds). | |
Set the starting time of Picture-in-Picture on the main video timeline (unit: microseconds). | |
Get the original media duration of Picture-in-Picture (unit: microseconds). | |
Gets the width (pixels) of the Picture-in-Picture source media. | |
Gets the height (in pixels) of the Picture-in-Picture source media. | |
Set the effective interval of Picture-in-Picture on the timeline and return to the current TAVPip, supports chain calls. | |
Set the position of Picture-in-Picture in the canvas (supports passing in PointFor x/y coordinates), returns the currentTAVPip, supports chain calls. | |
Set the overall zoom ratio of Picture-in-Picture and return the current TAVPip, supports chain calls. | |
Set the minimum zoom ratio allowed by Picture-in-Picture and return the current TAVPip, supports chain calls. | |
Set the maximum zoom ratio allowed by Picture-in-Picture and return the current TAVPip, supports chain calls. | |
Set the Picture-in-Picture rotation angle and return to the current TAVPip, supports chain calls. | |
Set whether the Picture-in-Picture is editable (whether to respond to gestures and other interactions), and return the current TAVPip, supports chain calls. | |
Clone the current Picture-in-Picture object and generate a new one with the same path, time interval, transformation parameters and other attributes. TAVPipExample. |
public String getPath()String public TAVMediaType getMediaType()TAVMediaType public float getVolume()float public void setVolume(float volume)Parameter | Type | Description |
volume | float | Picture-in-Picture volume, range is [0, 3], 1 is the original volume |
void public float getSpeed()float public void setSpeed(float speed)Parameter | Type | Description |
speed | float | Playback speed multiple, recommended range [0, 1] |
void public long getStartAtVideoUs()long public void setStartAtVideoUs(long startAtVideoUs)Parameter | Type | Description |
startAtVideoUs | long | The start time of Picture-in-Picture in the main video, unit: microsecond (us) |
void public long getOriginDuration()long public int getWidth()int public int getHeight()int TAVPipto support chained calls.public TAVPip setTimeRange(TAVTimeRange timeRange)Parameter | Type | Description |
timeRange | TAVTimeRange | Picture-in-Picture time range in timeline |
TAVPip TAVPip instance to facilitate chained calling.PointFspecified.public TAVPip setPosition(PointF point)Parameter | Type | Description |
point | PointF | Picture-in-Picture center position coordinates |
TAVPip TAVPip instance to facilitate chained calling.public TAVPip setPosition(float x, float y)Parameter | Type | Description |
x | float | X coordinate |
y | float | Y coordinate |
TAVPip TAVPip instance to facilitate chain calling.public TAVPip setScale(float scale)Parameter | Type | Description |
scale | float | scaling factor |
TAVPip TAVPip instance to facilitate chain calling.public TAVPip setMinScale(float minScale)Parameter | Type | Description |
minScale | float | Minimum zoom ratio |
TAVPip TAVPip instance to facilitate chain calling.public TAVPip setMaxScale(float maxScale)Parameter | Type | Description |
maxScale | float | Maximum zoom ratio |
TAVPip TAVPipInstance to facilitate chain calling.public TAVPip setRotate(float rotate)Parameter | Type | Description |
rotate | float | Rotation angle, unit: degrees |
TAVPip TAVPip instance to facilitate chain calling.public TAVPip setEditable(boolean editable)Parameter | Type | Description |
editable | boolean | Whether to allow editing |
TAVPip TAVPip instance to facilitate chain calling.TAVPipExample.public TAVPip clone()TAVPip extraInfofor the same reference).API | Description |
Set the path to the draft saving directory. This directory will be used for all subsequent draft reading and writing. | |
Read the list of all drafts in the current draft saving directory and return them in reverse chronological order. | |
Delete the draft files and directories corresponding to the specified draft object, and return whether the deletion is successful. | |
Delete all draft files and directories in the current draft saving directory, and return whether the deletion is successful. | |
Save the current editing status as a draft, use the given cover image path, and return the generated draft path, or null on failure. | |
Load the specified draft object and pass it after the loading is completed DraftLoadingCallback callback draft loading result. callback | |
Set up a draft status listener to monitor draft status changes such as whether it can be undone or redoed. | |
Reset the draft record and record the draft change history from the beginning. | |
Submit a draft snapshot. If the effect has not changed since the last submission, this submission will not take effect. Return whether it takes effect. | |
Determine whether there is currently a revocable draft record. | |
Determine whether there are currently redoable draft records. | |
Perform an undo operation by DraftActionCallback call back the difference result or error message generated by this switching draft.back callbackback callback | |
To perform a redo operation, pass DraftActionCallback call back the difference result or error message generated by this switching draft.back callback | |
Get the current draft model instance TAVDraft. | |
Set the draft component change listener, when the TAVDraftComponentCallback notification when changes occur. |
File.separator), will be automatically appended internally.public static void setDraftStorageDir(String storageDir)Parameter | Type | Description |
storageDir | String | The absolute path to the root directory where drafts are saved |
void public static List<TAVDraft> readDraftList()List<TAVDraft> public static boolean deleteDraft(TAVDraft draft)Parameter | Type | Description |
draft | TAVDraft | Draft objects that need to be deleted |
boolean draft == nullReturn directly whenfalsepublic static boolean deleteAllDrafts()boolean public abstract String generateDraft(String thumbPath)Parameter | Type | Description |
thumbPath | String | The path to the draft cover image file |
String null.public abstract void loadDraft(TAVDraft draft, DraftLoadingCallback callback)Parameter | Type | Description |
draft | TAVDraft | Draft object that needs to be loaded |
callback | Draft loading process and result callback |
void public abstract void setDraftStateListener(DraftStateListener listener)Parameter | Type | Description |
listener | Draft status listener implementation |
void public abstract void resetDraftRecord()void public abstract boolean commit(String tag)Parameter | Type | Description |
tag | String | The tag string for this submission |
boolean true Indicates that a new draft record is generated, false Indicates that the status has not changed and no new records have been generated.public abstract boolean canUndo()boolean true Indicates that the undo operation can currently be performed, false Indicates that there is no undoable record.public abstract boolean canRedo()boolean true Indicates that rollback/redo operations can currently be performed, false Indicates that there is no rollback record.DraftActionCallback Callback notification.public abstract void undo(DraftActionCallback callback)Parameter | Type | Description |
callback | Undo action result callback |
void public abstract void redo(DraftActionCallback callback)Parameter | Type | Description |
callback | Rollback action result callback |
void public abstract TAVDraft getCurrentDraft()TAVDraft public abstract void setDraftComponentObserver(DraftComponentObserver observer)Parameter | Type | Description |
observer | Draft component change listener instance |
void void onUndoStateChange(boolean canUndo)Parameter | Type | Description |
canUndo | boolean | Whether there is currently a reversible operation record status |
void void onRedoStateChange(boolean canRedo)Parameter | Type | Description |
canRedo | boolean | Whether there is currently a redoable operation record status |
void void onCheckoutDraft(String tag, TAVDiffResult diffResult)Parameter | Type | Description |
tag | String | The tag (TAG) passed in when submitting a draft is used to distinguish different submissions |
diffResult | TAVDiffResult | The change result model that occurred when switching drafts this time |
void void onError(int errorCode)Parameter | Type | Description |
errorCode | int | Error code, used to identify specific error types |
void loadDraft triggered after the draft recovery operation is completed, used to notify the business side of the result status and related information of this draft loading. is used to notify the business side of the result status and related information of this draft loading.void onDraftLoadingFinished(DraftLoadingResult result)Parameter | Type | Description |
result | Draft loading result model, including whether the loading was successful and additional information |
void TAVDraftComponent, this method will be triggered when changes occur (add, delete, update, etc.) to notify the business side to refresh the UI or synchronize the status.void onComponentUpdate(TAVDraftComponent component)Parameter | Type | Description |
component | TAVDraftComponent | Changed draft component instance |
void errors == null or errors.length == 0 is deemed to be loaded successfully.public boolean isSuccess()boolean true indicates that there are no errors in loading this draft;false indicates that there is at least one component loading error during the loading process.void onGenerateStarted()void 0-1 is returned in the form of a floating point number, and the calling frequency is controlled by the internal export process.void onGenerateProgress(float progress)Parameter | Type | Description |
progress | float | Export progress, ranging from 0.0 to 1.0 |
void TAVEditorGenerateResultstatus field distinction).void onGenerateCompleted(TAVEditorGenerateResult result)Parameter | Type | Description |
result | TAVEditorGenerateResult | Export result data model, such as export file path, status code, etc. |
void void onGenerateCanceled()void VideoConfigand audio configurationAudioConfig. TAVEditor.generateVideo(TAVEditorGenerateConfig config, String outputPath, TAVEditorGenerateListener listener)interface to achieve fine control over parameters such as export resolution, frame rate, bit rate, number of channels, etc.TAVEditorGenerateConfig when customizing the export configuration, adjust the video output quality and duration constraints by modifying the fields of this object.Parameter | Type | Description |
width | int | Export video width in pixels, default is 720. |
height | int | Export video height in pixels, default is 1280. |
frameRate | int | Export video frame rate (FPS), the default value is 30. |
videoBitRate | int | Video bit rate (bps, bits per second), the default value is approximately 720 * 1280 * 30 * 0.08, and the recommended range of bit rate factor is 0.05~0.1. |
profile | VideoConfig.Profile | H.264 encoding profile, default H264_BASE, optional: H264_BASE / H264_HIGH. |
maxGenerateDuration | long | Maximum export duration (microseconds), content exceeding this duration will be cropped; the default value is -1, which means no limit. |
minGenerateDuration | long | Minimum export duration (microseconds), an error will be reported if it is less than this duration; the default value is -1, which means no limit. |
Parameter | Type | Description |
channelCount | int | Number of channels, the default value is 1, optional: mono (1), stereo (2). |
sampleRate | int | Sampling rate (Hz), default value is 44100. |
audioBitRate | int | Audio bit rate (bps), the default value is 128000 (about 128kbps); uncompressed bitrate = sampling rate × bit depth × number of channels. |
void onPreviewProgress(long time)Parameter | Type | Description |
time | long | Current preview time, unit: us (microseconds) |
void void onStatusChanged(@Nullable TAVEditorConstants.EditorPlayerStatus status)Parameter | Type | Description |
status | TAVEditorConstants.EditorPlayerStatus|null | The current state of the player; may be null indicates unknown or uninitialized |
void TAVEditor.initWithPreview(PreviewParam param)、TAVEditor.fork(PreviewParam param)), specify the preview container, gesture layer, whether to automatically/loop playback, rendering scene, preview rendering size, etc.Parameter | Type | Description |
videoView | FrameLayout | The parent container View used to host the video preview screen. A rendering Surface, etc. will be created internally in this container. |
contentView | TAVWidgetContentView | Gesture operation layer View, used to carry touch events and display of interactive components such as stickers and Picture-in-Picture |
autoPlay | boolean | Whether to automatically start playing after preview initialization is completed, the default value is true |
loopPlay | boolean | Whether to loop playback and whether to automatically start from the beginning after playing to the end. The default value is true |
scene | int ( @RenderScene) | Usage scenario, default SCENE_PLAY SCENE_PLAY: Preview scene SCENE_EXPORT Export scene |
renderSize | Size|null | Specifies the rendering size (width and height), if null then the SDK automatically adapts according to the input material and container. |
constant name | Type | Description |
SCENE_PLAY | int | Preview scene, used for real-time preview and interactive rendering of editing pages |
SCENE_EXPORT | int | Export scenes for high-quality off-screen rendering and video export |
TAVPreviewListener.onStatusChangedThe callback notifies the business side of the current playback status so that the UI and logic control can be updated.enumeration value | Description |
IDLE | Idle state, not yet prepared or released |
READY | Ready for playback |
PLAYING | Now playing |
STOPPED | Stopped playing |
PAUSED | Playback paused |
COMPLETED | Playing to the end of the preset interval triggers the completion callback |
FINISHED | Playback process ends |
ERROR | An error occurred during playback |
REPLAY | Restart playback after completion (state triggered by loop playback) |
TAVEditor.generateVideo(@GenerateLevel int level, ...)is passed in as the export quality parameter.constant name | Type | Resolution description |
VIDEO_LEVEL_480P | int | Compressed to 480P (640×480) |
VIDEO_LEVEL_540P | int | Compressed to 540P (960×540) |
VIDEO_LEVEL_720P | int | Compressed to 720P (1280×720) |
VIDEO_LEVEL_1080P | int | Compressed to 1080P (1920×1080) |
constant name | Type | Description |
FILL_MODE_GAUSSIAN_BLUR | int | Use Gaussian Blur to process background fill |
FILL_MODE_SOLID_COLOR | int | Fill the canvas with a solid color background |
constant name | Type | Description |
PREVIEW_GL_THREAD | int | GL thread used by preview rendering |
GENERATE_GL_THREAD | int | Export the GL thread used for rendering |
setTemplateDir), a collection of error code constants.Constant Name | Type | Description |
SUCCESS | int | Set template directory successfully |
PATH_INVALID | int | Invalid template directory path |
AUTH_INVALID | int | Template authentication failed |
Error code | Error message | Description |
-1 | BuildRenderChainManager failed | Render chain creation exception 1 |
-4 | BuildRenderChainManager failed | Render chain creation exception 2 |
-10 | "error code ${errCode}: TAVMagic export error | Problem occurred during export completion |
-14 | | Video frame processing exception during export |
-15 | | Audio frame processing exception when exporting |
-16 | | Exporter initialization video decoding failed |
-17 | | Exporter initialization audio decoding failed |
-18 | | Failed to start encoding |
-19 | | Failed to start decoding |
-101 | "error code ${errCode}: TAVMagic export error | Failed to start video encoding |
-102 | | Failed to start audio encoding |
-103 | | Video encoding information configuration failed |
-104 | | Audio encoding information configuration failed |
-105 | Failed to create output file | Failed to create file |
-111 | "error code ${errCode}: TAVMagic export error | Export rendering exception 1 |
-112 | | Export rendering exception 2 |
-113 | | Export rendering exception 3 |
-121 | | Exception when writing video sample |
-122 | | Exception writing audio sample |
-123 | | End of writing video sample exception |
-124 | | End of writing audio sample exception |
-131 | | Stop muxer exception |
-132 | | Stop encoder exception |
-201 | Minimum generate duration cannot exceed maximum duration | The set minimum export duration is greater than the maximum export duration |
-202 | The total generate duration is shorter than the minimum required duration | The total duration is less than the minimum export duration |
-203 | Retry software encode error. Config is null. | Soft encoding retry failed, configuration file is empty |
-1001 | Load asset error | Exception loading resources |
피드백