SuperAPI AI Directory

byted-las-video-inpaint

Design & creation

View repository

Updated 10-15 17:30

About this skill

LAS Video Restoration (las_video_inpaint)

Remove watermarks, subtitles, and logos from videos. Supports restoration of specified fixed regions (fixed_bboxes). Multiple restoration backends are available.

Usage Limits: Video duration ≤ 4 hours, file size ≤ 30GB.

Design Patterns

This skill mainly adopts:

  • Tool Wrapper: Encapsulates the lasutil CLI call
  • Pipeline: Includes a sequential workflow from Step 0 → Step N

Core APIs and Configuration

  • Operator ID: las_video_inpaint
  • API: Asynchronous (submit → poll)
  • Environment Variables: LAS_API_KEY (Required)

For detailed parameters and interface definitions, see references/api.md。

Gotchas

  • Key Security: If the chat box blocks the key, have the user create env.sh in the current directory and write export LAS_API_KEY="...", and the SDK will read it automatically.
  • Disclaimer: When finally replying with results, you must include: "本方式的计费均为预估计费,与实际费用有差距,实际费用以运行后火山产生的账单为准。计费说明请参考 Volcengine LAS Pricing。", and it is forbidden to use the phrase "actual cost" to describe the estimated price.

Workflow (Execute Strictly in Steps)

Copy this checklist and track progress:

执行进度:
- [ ] Step 0: 前置检查
- [ ] Step 1: 初始化与准备
- [ ] Step 2: 预估价格
- [ ] Step 3: 提交任务
- [ ] Step 4: 异步查询
- [ ] Step 5: 结果呈现

Step 0: Pre-checks (⚠️ Must be completed in the first round of dialogue)

After accepting the user's task,do not start executing immediately; you must first perform the following environment checks:

  1. Check LAS_API_KEY and LAS_REGION: Confirm whether the environment variables or .env are configured.
    • If not, you must immediately ask the user for them (Hint:LAS_REGION is commonly cn-beijing)。
    • Note:LAS_REGION must be completely consistent with the region where your API Key and TOS Bucket are located. If the user switches Region midway, you must remind the user that their TOS Bucket also needs to be changed accordingly, otherwise it will cause permission exceptions or upload failures.
  2. Check input path:
    • If what the user requests to process is alocal file, it needs to first be uploaded to TOS via the File API (only LAS_API_KEY, no additional TOS credentials required).
    • If the operator'soutput resultis stored on TOS and the user needs to download it back locally, then VOLCENGINE_ACCESS_KEY and VOLCENGINE_SECRET_KEYare required. For scenarios whereonly input files need to be uploaded, TOS credentialsare no longer required。
  3. Check output path:
    • output_tos_path is a required parameter and must be provided by the usera writable TOS directory path of their own(Format:tos://bucket/output_dir/)。
    • The server needs to write the restored video to this directory.
  4. After confirming there are no errors: only then can you proceed to the next step.

Step 1: Initialization and Preparation

Environment initialization (required for Agent):

# 执行统一的环境初始化与更新脚本(会自动创建/激活虚拟环境,并检查更新)
source "$(dirname "$0")/scripts/env_init.sh" las_video_inpaint
workdir=$LAS_WORKDIR

If a network issue causes the update to fail, the script will skip the check and continue executing using the locally installed SDK.

  • When processing local files: Use the File API to upload (only LAS_API_KEY, no TOS credentials or Bucket required):
    lasutil file-upload <local_path>
    
    After a successful upload, return JSON and take the presigned_url(HTTPS presigned download link, valid for 24 hours) from it and pass it to the operator as the input URL.

Step 2: Estimate the price (⚠️ user confirmation is required)

  1. Read references/prices.md to obtain the latest billing standard.
  2. Obtain the video duration:
    lasutil media-duration <video_url>
    
  3. Calculate the total price based on the duration and the mode unit price,inform the user of the billing unit price together with the estimated total price and forcibly pause execution, and explicitly wait for the user's confirmation reply. Before the user explicitly replies with an approval instruction such as "continue" or "confirm",it is absolutely forbiddento proceed to the next step (execute/submit the task). Note: the estimate is for reference only; the actual amount is subject to the Volcengine bill. For billing details, please refer to Volcengine LAS Pricing。

Step 3: Submit the task (Submit)

Construct the basic data.json:

{
  "video_url": "<presigned_url>",
  "output_tos_path": "tos://<your-bucket>/output_dir/",
  "targets": ["watermark", "subtitle"]
}

Important note: output_tos_path must be provided by the user, and it needs to be a writable TOS directory under the user's own account (the server will write the repaired video into this directory).

Single-file submission:

data=$(cat "$workdir/data.json")
lasutil submit las_video_inpaint "$data" > "$workdir/submit.json"

⚠️ Mandatory feedback: after the task is submitted successfully,the generated task_idmust be returned to the user immediately, so that the user can track progress or manually check when necessary.

Step 4: Asynchronous polling (Poll)

⚠️ Constraints on asynchronous tasks and background polling:

  • If your current environmentsupports background tasks/long-running asynchronous execution: you may use the background capabilities provided by the environment (for example, launch a background polling task), and proactively return the result to the user after the task is completed.
  • If your current environmentdoes not supportlong-running background tasks (such as an ordinary single-turn conversation sandbox), and directly sleep looping will cause a timeout crash:It is absolutely forbidden to execute an infinite loop waiting in the code! In this case, you must immediately output the Task ID to the user and end the current turn, telling the user: "The task has been submitted; please ask me for progress later."

Single-task query:

lasutil poll las_video_inpaint {task_id}
  • COMPLETED → return the repaired video path result.data.inpainted_video_path。
  • RUNNING/PENDING → retry later.

Step 5: Present the result

Processing result:

# 获取修复后的视频 URL
inpainted_url=$(cat "./output/{task_id}/result.json" | jq -r '.data.inpainted_video_path')
echo "修复后的视频: $inpainted_url"

Video file:

  • The repaired video has been saved in TOS; directly return the presigned URL
  • No need to upload again

Show the user:

  1. Download link for the repaired video
  2. Local result path:./output/{task_id}/
  3. Billing statement

Review standards

After execution is completed, the Agent should self-check:

  1. Whether the environment variables are configured correctly
  2. Whether the input file was uploaded successfully
  3. Whether the output result is correctly presented to the user
  4. Whether the billing statement is included