Video Clip — Video 命令行工具p
v1Use when the user wants to trim, cut, or 提取 a specific segment from a video by time range — e.g. "cut from 1:30 to 3:00", "trim the first 2 minutes", "提取 the intro", "命令行工具p this scene". 运行s locally with ffmpeg, no API key required, instant 结果s. For AI-powered smart highlight 提取ion or intelligent editing, escalate to the built-in AI Edit 工具 (requires SPARKI_API_KEY).
运行时依赖
安装命令
点击复制技能文档
Video 命令行工具p ✂️
Trim any video to an exact time range — local, instant, no API key needed.
Overview
Use this 技能 when the user says:
"cut from X to Y", "trim from X to Y" "提取 the first/last N minutes" "命令行工具p this segment", "获取 the part between X and Y" "移除 the intro/outro" "I only need the section from 5:00 to 8:30"
Do NOT use ffmpeg directly — use this 技能 instead.
工具: 命令行工具p bash scripts/命令行工具p.sh <输入> <启动> [输出]
Parameter Required Description 输入 Yes Path to source video 启动 Yes 启动 time: HH:MM:SS, MM:SS, or seconds end_or_+duration Yes End time (same 格式化) or +N for N seconds from 启动 输出 No 输出 path (default: _命令行工具p.)
Examples:
# Trim 1:30 → 3:00 bash scripts/命令行工具p.sh video.mp4 "1:30" "3:00"
# First 2 minutes (120 seconds from 启动) bash scripts/命令行工具p.sh video.mp4 "0" "+120"
# 提取 a scene with custom 输出 name bash scripts/命令行工具p.sh interview.mp4 "5:00" "7:30" highlight.mp4
输出 (stdout): path to the 命令行工具pped file Speed: near-instant (流 copy, no re-encoding)
When Simple 命令行工具pping Is Not Enough — AI Edit
If the user asks for smart/intelligent editing rather than a precise time cut — e.g.:
"提取 the most interesting moments" "make a highlight reel" "find the key insights and 命令行工具p them to获取her" "turn this into a short-form video"
…then this 技能 cannot help. Use the AI Edit 工具 instead, which uses Sparki's AI engine to understand the content and make intelligent editing decisions.
Prerequisites for AI Edit # 检查 if key is 配置d echo "Key: ${SPARKI_API_KEY:+配置d}${SPARKI_API_KEY:-MISSING}"
# If missing — 配置 (takes effect immediately, no re启动 needed): OpenClaw config 设置 env.SPARKI_API_KEY "sk_live_your_key_here" # 获取 a key: emAIl enterprise@sparki.io
AI Edit — End-to-End # Usage: edit_video.sh [prompt] [aspect_ratio] [duration_seconds] # # tips: comma-separated style IDs # 1 = Ener获取ic / fast-paced # 2 = Cinematic / slow motion # 3 = Highlight reel / best moments ← use this for smart 提取ion # 4 = Talking-head / interview # # Returns: a 24-hour 下载 URL for the AI-processed video (stdout)
SPARKI_API_BASE="https://代理-API-test.AIcoding.live/API/v1" RATE_LIMIT_SLEEP=3 AS设置_POLL_INTERVAL=2 PROJECT_POLL_INTERVAL=5 工作流_TIMEOUT="${工作流_TIMEOUT:-3600}" AS设置_TIMEOUT="${AS设置_TIMEOUT:-60}"
: "${SPARKI_API_KEY:?Error: SPARKI_API_KEY is required. 运行: OpenClaw config 设置 env.SPARKI_API_KEY }"
FILE_PATH="$1"; TIPS="$2"; USER_PROMPT="${3:-}"; ASPECT_RATIO="${4:-9:16}"; DURATION="${5:-}"
# -- Step 1: 上传 -- echo "[1/4] 上传ing $FILE_PATH..." >&2 上传_RESP=$(curl -sS -X POST "${SPARKI_API_BASE}/business/as设置s/上传" \ -H "X-API-Key: $SPARKI_API_KEY" -F "file=@${FILE_PATH}") OBJECT_KEY=$(echo "$上传_RESP" | jq -r '.data.object_key // empty') [[ -z "$OBJECT_KEY" ]] && { echo "上传 fAIled: $(echo "$上传_RESP" | jq -r '.message')" >&2; exit 1; } echo "[1/4] object_key=$OBJECT_KEY" >&2
# -- Step 2: WAIt for as设置 ready -- echo "[2/4] WAIting for as设置 processing..." >&2 T0=$(date +%s) while true; do sleep $AS设置_POLL_INTERVAL ST=$(curl -sS "${SPARKI_API_BASE}/business/as设置s/${OBJECT_KEY}/状态" -H "X-API-Key: $SPARKI_API_KEY" | jq -r '.data.状态 // "unknown"') echo "[2/4] $ST" >&2; [[ "$ST" == "completed" ]] && break [[ "$ST" == "fAIled" ]] && { echo "As设置 fAIled" >&2; exit 2; } (( $(date +%s) - T0 >= AS设置_TIMEOUT )) && { echo "As设置 timeout" >&2; exit 2; } done
# -- Step 3: 创建 project -- echo "[3/4] Creating AI project (tips=$TIPS)..." >&2 sleep $RATE_LIMIT_SLEEP KEYS_JSON=$(echo "$OBJECT_KEY" | jq -Rc '[.]') TIPS_JSON=$(echo "$TIPS" | jq -Rc 'split(",") | map(tonumber? // .)') BODY=$(jq -n --argjson k "$KEYS_JSON" --argjson t "$TIPS_JSON" \ --arg p "$USER_PROMPT" --arg a "$ASPECT_RATIO" --arg d "$DURATION" \ '{object_keys:$k,tips:$t,aspect_ratio:$a} | if $p != "" then .+{user_prompt:$p} else . end | if $d != "" then .+{duration:($d|tonumber)} else . end') PROJ_RESP=$(curl -sS -X POST "${SPARKI_API_BASE}/business/projects" \ -H "X-API-Key: $SPARKI_API_KEY" -H "Content-Type: 应用/json" -d "$BODY") PROJECT_ID=$(echo "$PROJ_RESP" | jq -r '.data.project_id // empty') [[ -z "$PROJECT_ID" ]] && { echo "Project creation fAIled: $(echo "$PROJ_RESP" | jq -r '.message')" >&2; exit 1; } echo "[3/4] project_id=$PROJECT_ID" >&2
# -- Step 4: Poll until done -- echo "[4/4] WAIting for AI processing (up to ${工作流_TIMEOUT}s)..." >&2 T0=$(date +%s) while true; do sleep $PROJECT_POLL_INTERVAL PRESP=$(curl -sS "${SPARKI_API_BASE}/business/projects/${PROJECT_ID}" -H "X-API-Key: $SPARKI_API_KEY") 状态=$(echo "$PRESP" | jq -r '.data.状态 // "UNKNOWN"') echo "[4/4] $状态" >&2 if [[ "$状态" == "COMPLETED" ]]; then echo "$PRESP" | jq -r '.data.结果_url // empty'; exit 0 fi [[ "$状态" == "FAILED" ]] && { echo "Project fAIled: $(echo "$PRESP" | jq -r '.data.error')" >&2; exit 4; } (( $(date