Communitygithub.com

FilippTrigub/abra

将视频切割成片段,重新排列顺序,并以指定的每秒切割率生成输出视频。使用 MoviePy 进行视频处理,优先通过音频转录进行时间戳切割,回退到自适应场景检测。

abra 是什么?

此 AI 技能允许开发者将视频文件切割成多个片段,重新排列这些片段,并以用户定义的帧率(每秒帧数)输出最终视频。它利用 MoviePy 库进行底层视频处理,核心逻辑是根据音频转录结果自动确定最佳切割点,从而生成更自然的、与语音内容对齐的视频片段。当音频转录功能不可用或失败时,技能会自动回退到自适应场景检测算法,通过分析视频画面变化来识别场景切换点。该技能支持多种配置选项,例如最小/最大片段时长、检测模式(自适应、内容、阈值)以及高级参数如像素差异阈值。最终输出是一个拼接后的 MP4 视频文件,保留原始音频。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/FilippTrigub/abra/tree/HEAD/skills/video-cutter

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

snip — 视频切割与重新排列

将视频切割成片段,重新排序,并以指定的帧率导出。 适用于制作精彩集锦、重新排列场景或改变视频节奏。

技能目录(即此 SKILL.md 所在目录)在下文中称为 $SKILL_DIR。


使用时机

当用户希望执行以下操作时使用此技能:

  • 将视频切割成特定片段
  • 以不同顺序重新排列视频片段
  • 移除视频中不需要的部分
  • 更改输出帧率(每秒帧数)
  • 自动检测语音片段以实现自然切割(优先)
  • 作为回退方案,自动检测场景变化

设置(仅首次运行)

cd "$SKILL_DIR" && uv sync

代理工作流程

1. 询问用户

在切割视频之前,我需要了解以下信息:

📹 源视频
   列出视频文件及其位置

✂️ 要切割的片段
   对于每个片段,请指定:
   - source: 文件名
   - start: 起始时间(秒,例如 0.0, 5.5)
   - end: 结束时间(秒,例如 2.0, 10.0)
   
   示例片段:
   [
     {"source": "video.mp4", "start": 0.0, "end": 1.0},
     {"source": "video.mp4", "start": 3.0, "end": 4.5},
     {"source": "video.mp4", "start": 1.5, "end": 2.5}
   ]

🎬 输出帧率(可选)
   默认值:30 fps
   常用选项:24, 30, 60

📁 输入/输出目录(默认:./input 和 ./输出)

等待用户响应后再继续。

2. 确定切割策略

优先级顺序:

  1. 显式片段 — 如果用户提供了具体的起止时间,则直接使用
  2. 音频转录 — 如果 transcription.enabled: true(默认),则查找或生成转录,并在语音片段边界处切割
  3. 自适应场景检测 — 如果转录不可用或失败,则作为回退方案

音频转录(主要方法)

该技能将首先尝试使用音频转录从视频中获取带时间戳的语音片段。这能产生与语音内容对齐的更自然的切割。

🤖 音频转录模式(优先)

切割器将:
1. 在输出目录中查找现有的转录 JSON(例如 video_transcription.json)
2. 如果未找到,则自动运行音频转录
3. 在语音片段边界处切割视频

⚙️ 配置:
   - transcription.enabled: true(默认)
   - fallback_to_adaptive: true(默认)— 如果转录失败,则使用场景检测
   - min_segment_duration: 每段最小时长(秒,默认:1.0)
   - max_segment_duration: 每段最大时长(秒,默认:30.0)

示例配置:
{
  "segments": [{"source": "video.mp4", "start": 0, "end": 60}],
  "transcription": {
    "enabled": true,
    "fallback_to_adaptive": true,
    "min_segment_duration": 1.0,
    "max_segment_duration": 30.0
  }
}

自适应场景检测(回退方案)

如果转录被禁用或失败,该技能将回退到视觉场景检测:

🎬 自适应场景检测(回退方案)

自动检测视频中的场景变化以创建切割点。
通过在自然过渡点切割,避免无聊、重复的内容。

⚙️ 检测模式:
   - adaptive  — 最适合光照变化/渐变场景 [默认]
   - content   — 最适合快速、清晰的场景切换
   - threshold — 最适合检测淡入/淡出

📏 场景时长过滤器:
   - min_scene_duration: 每段最小时长(秒,默认:1.0)
   - max_scene_duration: 每段最大时长(秒,默认:10.0)

🎛️ 高级选项(可选):
   - threshold: content 模式的像素差异阈值(默认:27.0)
   - adaptive_threshold: adaptive 模式的比率阈值(默认:3.0)
   - window_width: 平均帧数(默认:2)
   - min_scene_len: 切割前的最小帧数(默认:15)
   - min_content_val: 最小内容变化(默认:15.0)

使用自动检测回退的示例配置:
{
  "segments": [{"source": "video.mp4", "start": 0, "end": 60}],
  "transcription": {
    "enabled": false
  },
  "auto_detect": {
    "enabled": true,
    "mode": "adaptive",
    "min_scene_duration": 1.0,
    "max_scene_duration": 10.0
  }
}

3. 编辑 config.json

根据用户选择编写或更新 $SKILL_DIR/config.json。

4. 运行

cd "$SKILL_DIR" && uv run python scripts/cutter.py --config config.json

5. 报告结果

告知用户输出文件路径、时长和帧率。说明使用了哪种方法(基于转录或场景检测)。


配置参考

键值默认值描述
input_dir路径./input包含输入视频的文件夹
output_dir路径./output目标文件夹
segments数组(必需)片段定义列表
output_fps整数30输出帧率

片段定义

键类型描述
source字符串input_dir 中的文件名
start浮点数起始时间(秒)
end浮点数结束时间(秒)

转录(优先方法)

键值默认值描述
enabled布尔值true启用基于转录的切割
fallback_to_adaptive布尔值true如果转录失败,使用场景检测
min_segment_duration浮点数1.0跳过短于此值的片段(秒)
max_segment_duration浮点数30.0跳过长于此值的片段(秒)

自动检测(回退方案)

键值默认值描述
enabled布尔值false启用自动场景检测(仅回退)
modeadaptive、content、thresholdadaptive检测算法
min_scene_duration浮点数1.0跳过短于此值的场景(秒)
max_scene_duration浮点数10.0跳过长于此值的场景(秒)
threshold浮点数27.0content/threshold 模式的像素差异阈值
adaptive_threshold浮点数3.0adaptive 模式的比率阈值
window_width整数2前后平均的帧数
min_scene_len整数15切割前的最小帧数
min_content_val浮点数15.0最小内容变化

检测模式(回退)

  • adaptive(默认):最适合光照变化或渐变过渡的视频
  • content:最适合具有清晰、锐利场景切换的视频
  • threshold:最适合检测淡入/淡出过渡

常见调用

# 默认配置(如果可用则使用转录,否则回退到 adaptive)
cd "$SKILL_DIR" && uv run python scripts/cutter.py --config config.json

# 强制使用自适应场景检测(跳过转录)
cd "$SKILL_DIR" && uv run python scripts/cutter.py --config config.json --no-transcription

# 自定义目录
cd "$SKILL_DIR" && uv run python scripts/cutter.py \
  --input /path/to/videos --output /path/to/output

输出

每个配置会在 output_dir 中生成一个 output.mp4,其中包含拼接后的片段。音频会从原始视频片段中保留。


错误处理

  • 未定义片段 → 输出错误信息,退出
  • 无效的片段时间 → 显示清晰错误及期望格式
  • 源视频未找到 → 显示文件未找到错误
  • 转录失败 → 如果启用了回退则切换到 adaptive,否则报错
  • 单个片段错误 → 记录日志;其他片段继续处理

Individual skills in this repo

This repo contains 7 individual skills — each has its own dedicated page.

FilippTrigub/abra

>- Animate a still image into a short video clip using fal.ai's LTX-2.3 Fast image-to-video model in the cloud. No GPU required - runs entirely on fal.ai serverless infrastructure.

FilippTrigub/abra

>- Auto-describe and caption images using a local vision-language model. Writes a JSON sidecar per image containing a one-sentence description, a suggested Instagram caption with hashtags, and detected content tags.

FilippTrigub/abra

>- Animated caption pipeline. Use this skill when the user wants to burn word-by-word animated captions into videos — using Whisper for transcription and pycaps for rendering. Supports default minimalist style or a futuristic CSS theme with alternating gold/magenta glowing words.

FilippTrigub/abra

>- Edit a region of a video using a text prompt via Wan2.1-VACE inpainting. Supports two modes: background (auto-segment via rembg) or region (rectangle defined by fractions). Requires a CUDA GPU with at least 8 GB free VRAM.

FilippTrigub/abra

>- Video enhancement pipeline. Use this skill when the user wants to sharpen, colour grade, warm, or normalise the audio of videos — including presets for natural, cinematic, or vivid looks.

FilippTrigub/abra

Generate videos from text or images using Higgsfield's multi-model cloud platform. Supports kling, seedance, dop, and dop-preview models. Uses a small preset layer for common creative styles. Auto-detects text-to-video or image-to-video based on input. No GPU required.

FilippTrigub/abra

>- Remove the background from every frame of a video using AI (BiRefNet-general via rembg). Outputs transparent-background video or composites onto a solid colour or image. Requires a CUDA GPU with at least 3 GB free VRAM.

相关技能