Communitygithub.com

Video Editing

Used when a user needs to edit videos, splice clips, add title images, extract frames/audio tracks, and export to MP4 (Android host weizhi:video). Not applicable on desktop without MediaCodec.

What is Video Editing?

This skill provides video editing capabilities within an Android environment using the `weizhi:video` package. It supports probing, frame extraction, audio track extraction, and MP4 export (exportVideo) with two timeline modes. Version 1 is for simple operations like trimming segments and concatenating without re-encoding, using a clips array. Version 2 supports multi-track timelines with image tracks (title cards, Ken Burns effect), video tracks, audio tracks, and crossfade transitions between images. It requires loading the skill (`load_skill`) and checking capabilities (`find_caps`) before writing scripts. Scripts must be placed in `jobs/*.js` and executed via `run_js` with `file`. The skill provides specific API signatures and examples to avoid errors. Key constraints include: no overlapping clips without explicit transitions, crossfade duration must be precisely matched by offsetting start times, and opacity keyframes cannot be mixed with transitions. The recommended workflow involves probing source videos first, then exporting intermediate parts if needed, and finally composing with version 2. Final output is shared as a link to the resulting MP4 file.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/fengshihao/agent1-skills/tree/main/skills-src/video-edit

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Preview

From the skill README

Documentation

Video Editing (weizhi:video)

Scope

DoDo Not
probe, extract frames/audio tracks, exportVideo exportDecode an entire mp4 with webview_exec
v1 remux: trim, concatenate without fadingPretend to support desktop transcoding (desktop does not have this package)

Initiation Protocol

  1. First load_skill (video-edit) to read this document.
  2. Before writing exportVideo or a complex timeline: find_caps once (query includes exportVideo weizhi:video or a specific capability), and write according to the returned call example; do not guess field names.
  3. Place scripts in jobs/*.js, execute using run_js with file; timeout_ms can be increased (max 600000).
  4. If the script API returns an error (such as bad argument, unsupported): find_caps again to check the signature and modify the script.

Routing

TaskAPI
Trim a single segment, concatenate multiple segments end-to-end, no re-encodingv1 exportVideo({ clips: [{ path, startMs?, endMs? }], output })
Multi-track, image title card, Ken Burns, crossfadev2 exportVideo({ width, height, tracks, output })

Timeline v2 (Key Points)

  • Image / photo: type: "image" track, durationMs is mandatory.
  • mp4 segment: type: "video" track, inMs / outMs; do not put images in a video track.
  • Crossfade (image tracks only): the later clip should have transition: { type: "crossfade", durationMs: D }, and
    startMs_next = startMs_prev + durationMs_prev - D (overlap exactly D milliseconds). There is no crossfadeMs field.
  • Clips on the same track without a declared transition must not overlap in time; an error overlapping clips means you should check the above formula and transition.
  • transition and self-written opacity keyframes cannot be used simultaneously.
  • Audio track: type: "audio" as a separate track.

Example (two images crossfade + then video):

import { exportVideo } from "weizhi:video";

const D = 300;
await exportVideo({
  width: 720,
  height: 1280,
  tracks: [
    {
      type: "image",
      clips: [
        { src: "a.jpg", startMs: 0, durationMs: 1000 },
        {
          src: "b.jpg",
          startMs: 1000 - D,
          durationMs: 1000,
          transition: { type: "crossfade", durationMs: D },
        },
      ],
    },
    {
      type: "video",
      clips: [{ src: "clip.mp4", startMs: 1700, inMs: 0, outMs: 5000 }],
    },
  ],
  output: "out/final.mp4",
});

Recommended Workflow

  1. probe the source video for duration and resolution.
  2. If a cover frame is needed: extractFrame / extractFrames (see find_caps).
  3. For complex videos: you can first export intermediate part1.mp4, part2.mp4 using v1, then concatenate using v1 or v2; avoid stacking clips without declared transitions on one track.
  4. Background music: a separate audio track, outMs aligned with the total video length.

Scripting

  • A single jobs/render.js script should handle probing, export, and verification (you can probe the final output again) in sequence.
  • Do not replace the entire script with multiple tools from outside.

How to Communicate with the User

Specify the output file name and duration; use a [Video](out/xxx.mp4) link. Avoid stacking technical terms.

Related Skills