Capabilities and Preparation
Use subtitle to create dynamic subtitles or update subtitle styles for videos, improving information delivery and viewing experience, output a new video and retain the original materials. Depends on meitu-kaipai-cli, verified target version 0.1.8, compatible with >=0.1.8 <0.2.0。
On first execution, readPlatform Access, parse the CLI entry point, check the version and subtitle --help file parameters. When JSON fields or media restrictions are unclear, query the kaipai contracts entries in subtitle according to the platform instructions; when encountering output parsing, inquiries, or exceptions, readRun and Recovery。
- Create subtitles based on recognizable speech or an existing usable subtitle timeline; when the subtitle content source is missing, first fill in usable materials.
- When there is a configured valid subtitle style ID, specify it via
--subtitle-material-id; when not specified, inform that a random style will be used and omit this parameter. Use style IDs according to the actual configuration, and record them separately from session media IDs. - When the user raises editing requirements such as subtitle text, translation, key words, or position, first verify the current command and available styles, and address the specific needs according to the platform instructions. Use the video subtitle removal capability to remove original subtitles in the frame, and connect it with dynamic subtitle creation according to the user's goal.
- Directly execute clear subtitle addition requests; for requests with unclear goals such as "enhance expression," only ask follow-up questions about the processing method. Arrange mixed editing or original subtitle cleanup according to the user's actual needs.
Collect Input
- Use the real video file or URL from the current request; when the information is complete, do not ask repeatedly. When there are multiple candidates and the target is unclear, ask the user to choose and do not automatically choose on their behalf.
- For local videos, use a real readable path; for all remote videos, first followPlatform Accessto download the original resource, then upload it as a local file. If the download fails, ask the user to download it themselves and provide the local original file, and continue the original subtitle request after receiving it.
- When continuing a task, add
-r '<session_id>'; omit for new tasks. Optional--lang / --detach / --subtitle-material-idis passed according to the current help, and omitted when not specified; default values and login are handled according to the platform instructions. - When continuing mixed editing, retain the original session, obtain the complete video URL of this Artifact or Message Part, download it first, then upload it to your own CDN. If it is missing, expired, or only a media ID is available, first query the Task/history. Save the original source and the actual local path, do not first
create-room / add-media, and do not use--item-id。
Upload and Submit
Use the parsed CLI entry point to pass the prepared local video as an independent parameter:
kaipai subtitle --video-file '<本地视频路径>'
After the CLI validates the local video, first upload it to obtain your own CDN URL, then submit the subtitle task and by default wait for this execution to end. Use parameter files and independent pre-checks as needed; retain the original video and session for recovery. For secure parameter passing and temporary file cleanup, see the platform instructions.
Follow-up and Delivery
- Save the real
session_id / room_url, all Task IDs, artifactviva.short_idand complete URLs; read the original command stdout and stderr separately, and do not open separate polling at the same time. TASK_STATE_COMPLETEDand only deliver the finished video after obtaining a usable video URL for this execution. HTTP 200, stream end, exit code 0, Session idle, orend.reason=resultdo not individually prove completion; unknown status cannot be regarded as success.- Prioritize providing a playable video or a complete clickable link, preserving query parameters; when there is an actual
room_urlappend the session entry point. Do not treat the cover image or the input video as the subtitle result. - When the connection drops, times out, or the acceptance status is unknown, query the original task first; do not automatically regenerate. Retry only after the failure cause has been fixed and the user has authorized it; if subtitles fail, deliver the successfully mixed-cut video and explain that the subtitles were not completed; if downloading the output artifact fails, handle only the download. For detailed recovery and saving methods, see the operating instructions.