AgentSkillsCN

video-editor

通过 FFmpeg 编辑视频,采用类似 Git 的暂存工作流和平台预设。 当用户请求:(1) 剪切/修剪/编辑视频,(2) 转换格式或编解码器, (3) 优化适用于平台(WhatsApp、Instagram、YouTube、Twitter、Telegram), (4) 提取音频或创建 GIF,(5) 获取视频信息/元数据,(6) 旋转/调整大小/裁剪, (7) 加快/减慢视频,(8) 压缩视频,(9) 合并多个视频时使用。所有操作都进入暂存区,再经最终批准。支持操作历史、回放、批处理以及撤销/重做。

SKILL.md
--- frontmatter
name: video-editor
description: |
  Video editing via FFmpeg with git-like staging workflow and platform presets.
  Use when the user asks to: (1) cut/trim/edit videos, (2) convert formats or codecs,
  (3) optimize for platforms (WhatsApp, Instagram, YouTube, Twitter, Telegram),
  (4) extract audio or create GIFs, (5) get video info/metadata, (6) rotate/resize/crop,
  (7) speed up/slow down videos, (8) compress videos, (9) concatenate multiple videos.
  All operations go to staging before final approval. Supports operation history,
  replay, batch processing, and undo/redo.

Video Editor

FFmpeg-based video editing with a git-like staging workflow. All operations generate a preview in staging that must be approved before the final file is created.

Workflow

  1. Execute FFmpeg with output to ~/.video-editor/staging/{id}/output.{ext}
  2. Save metadata: python scripts/staging_save.py {id} --original {file} --operation {op} --command "{cmd}" --params '{json}'
  3. Open preview: python scripts/staging_preview.py {id}
  4. Wait for user approval
  5. If approved: python scripts/staging_approve.py {id} --output {destination}
  6. If rejected: python scripts/staging_discard.py {id}

Staging Scripts

All scripts are in the scripts/ directory. Always use full path from skill base directory.

ScriptPurpose
staging_save.pySave operation metadata after FFmpeg execution
staging_approve.pyMove staged file to final destination, record in history
staging_discard.pyRemove staged file and metadata
staging_preview.pyOpen staged file in configured player (mpv/vlc)
staging_status.pyList all pending staged files

History & Advanced Workflow

ScriptPurpose
history.pyList/show past operations
history_replay.pyRe-apply an operation to a different file
batch_run.pyExecute FFmpeg command on multiple files
backup_create.pyCreate backup before destructive operation
backup_restore.pyRestore from backup (undo/redo)

FFmpeg Commands

For FFmpeg command patterns and best practices, see references/operations.md.

Platform Presets

For platform-specific encoding settings (WhatsApp, Instagram, YouTube, etc.), see references/presets.md.

Troubleshooting

For common issues and solutions, see references/troubleshooting.md.

Logs

All operations are logged to ~/.video-editor/logs/video-editor.log.

Configure logging in ~/.video-editor/config.json:

json
{
  "log_level": "INFO",
  "log_max_size_mb": 10,
  "log_backup_count": 3
}

Directory Structure

code
~/.video-editor/
├── staging/{id}/          # Preview files pending approval
│   ├── output.{ext}       # The generated file
│   └── metadata.json      # Operation details
├── backups/{id}/          # Backups for undo/redo
│   └── original.{ext}
├── logs/                  # Operation logs
│   └── video-editor.log   # Rotating log file
├── history.json           # All completed operations
├── undo_stack.json        # Operations available for redo
└── config.json            # User preferences

Config Options

The ~/.video-editor/config.json file supports:

json
{
  "player": "mpv",           // Preview player: mpv, vlc, xdg-open
  "default_output_dir": ".", // Default output directory
  "auto_preview": true,      // Auto-open preview after staging
  "keep_original": true      // Never overwrite original files
}