ffmpeg

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

FFmpeg

FFmpeg

CLI skill for local audio/video inspection and transformation via
ffmpeg
and
ffprobe
. Invoke as
/ffmpeg
.
Scope: Probe metadata, trim clips, transcode containers/codecs, concatenate segments, extract audio, capture thumbnails, and build GIF previews from files on disk. NOT for AI image or video generation (
draw-thing
), UI or layout design (
design
), networked downloads (
yt-dlp
), or broadcast/streaming pipelines.

一款基于
ffmpeg
ffprobe
的CLI工具,用于本地音视频文件的检查与转换。调用方式为
/ffmpeg
适用范围: 探测元数据、修剪片段、转码容器/编码格式、拼接视频段、提取音频、截取缩略图、从本地磁盘文件生成GIF预览。不支持AI图像/视频生成(
draw-thing
)、UI/布局设计(
design
)、网络下载(
yt-dlp
)或直播/流媒体工作流。

Canonical Vocabulary

标准术语定义

TermMeaningNOT
probeRead-only ffprobe inspectiontranscode
trimShorten by time rangecrop UI mockup
transcodeRe-mux or re-encode to new container/codecgenerate new imagery
concatJoin multiple inputs sequentiallymerge git branches
extract-audioStrip video, keep audio trackspeech-to-text
thumbnailSingle still frame from videodesign a poster layout
gifAnimated GIF preview from video clipCSS animation
stream copy
-c copy
without re-encode
always safe for all trims
recipeApproved command template from
references/
ad-hoc filter graph

术语含义排除场景
probe只读式ffprobe探测转码
trim按时间范围缩短视频裁剪UI原型
transcode重新封装或重新编码为新容器/编码格式生成新图像
concat按顺序合并多个输入文件合并Git分支
extract-audio剥离视频,保留音轨语音转文字
thumbnail从视频中提取单帧静态画面设计海报布局
gif从视频片段生成动画GIF预览CSS动画
stream copy使用
-c copy
参数不重新编码
并非适用于所有修剪场景
recipe来自
references/
目录的已批准命令模板
临时自定义滤镜图

Dispatch

命令调度

$ARGUMENTS
ModeAction
doctor
/
check
/
preflight
DoctorRun PATH doctor; stop if ffmpeg/ffprobe missing
probe <path>
/
info <path>
/
metadata <path>
ProbeRun probe helper; summarize streams and duration
trim <path> <start> <end>
/
clip <path> ...
TrimProbe, pick copy vs re-encode recipe, new output path
transcode <path>
/
convert <path> to mp4
TranscodeProbe codecs; apply H.264/AAC or copy recipe
concat <file1> <file2> [...]
/
join ...
ConcatVerify probes; concat demuxer recipe + new output
extract-audio <path>
/
audio <path>
Extract audioProbe audio stream; MP3/M4A/copy recipe
thumbnail <path>
/
thumb <path> [timestamp]
ThumbnailSeek frame; write JPG/PNG to new path
gif <path>
/
animate <path> [start] [duration]
GIFPalette GIF recipe with duration cap
Path to media + natural language edit intentAutoClassify trim/transcode/thumbnail/gif from intent
(empty)HelpShow modes, critical rules, script commands, references
$ARGUMENTS
参数
模式操作
doctor
/
check
/
preflight
环境检查运行PATH检查;若ffmpeg/ffprobe缺失则终止操作
probe <path>
/
info <path>
/
metadata <path>
文件探测运行探测工具;汇总流信息和时长
trim <path> <start> <end>
/
clip <path> ...
视频修剪探测源文件,选择复制或重新编码方案,生成新输出路径
transcode <path>
/
convert <path> to mp4
格式转码探测编码格式;应用H.264/AAC或直接复制方案
concat <file1> <file2> [...]
/
join ...
文件拼接验证探测结果;使用拼接解复用器方案并生成新输出文件
extract-audio <path>
/
audio <path>
音频提取探测音轨;应用MP3/M4A/直接复制方案
thumbnail <path>
/
thumb <path> [timestamp]
缩略图截取定位帧位置;将JPG/PNG写入新路径
gif <path>
/
animate <path> [start] [duration]
GIF生成使用调色板GIF方案,限制时长上限
媒体文件路径+自然语言编辑需求自动识别根据需求分类为修剪/转码/缩略图/GIF模式
(空参数)帮助显示模式说明、核心规则、脚本命令和参考文档

Auto-Detection Heuristic

自动识别规则

  1. Install/tooling doubt → Doctor.
  2. "metadata", "codec", "duration", "how long", "what format" → Probe.
  3. "cut", "clip", "from ... to ...", time range → Trim.
  4. "mp4", "webm", "h264", "aac", "smaller", "compress" → Transcode.
  5. "join", "merge clips", "append videos" → Concat.
  6. "mp3", "wav", "m4a", "strip video", "audio only" → Extract audio.
  7. "poster frame", "screenshot", "still", "thumbnail" → Thumbnail.
  8. "gif", "animated preview" → GIF.
  9. Generative image/video language → refuse; redirect to
    draw-thing
    .
  10. UI/page/layout design → refuse; redirect to
    design
    .
  11. Ambiguous → ask which mode and state copy vs re-encode tradeoff.

  1. 安装/工具疑问 → 环境检查
  2. 包含"metadata"、"codec"、"duration"、"时长"、"格式" → 文件探测
  3. 包含"cut"、"clip"、"从...到..."、时间范围 → 视频修剪
  4. 包含"mp4"、"webm"、"h264"、"aac"、"缩小"、"压缩" → 格式转码
  5. 包含"join"、"合并片段"、"追加视频" → 文件拼接
  6. 包含"mp3"、"wav"、"m4a"、"剥离视频"、"仅保留音频" → 音频提取
  7. 包含"海报帧"、"截图"、"静态画面"、"缩略图" → 缩略图截取
  8. 包含"gif"、"动画预览" → GIF生成
  9. 生成式图像/视频相关描述 → 拒绝请求;引导至
    draw-thing
  10. UI/页面/布局设计相关描述 → 拒绝请求;引导至
    design
  11. 需求模糊 → 询问用户选择模式,并说明复制与重新编码的权衡

Critical Rules

核心规则

  1. Probe before mutate — run
    probe_media.py
    on every source file before trim, transcode, concat, extract-audio, thumbnail, or gif. Use probe fields to choose maps, codecs, and duration bounds. See
    references/probe-fields.md
    .
  2. Never overwrite in-place (default) — always write to a new output path. In-place replace requires explicit user approval plus backup/temp-file replace. See
    references/safety.md
    .
  3. Recipe-only mutations — build ffmpeg commands only from
    references/recipes-trim-transcode.md
    and
    references/recipes-thumbnail-gif.md
    . No improvised filter chains or destructive batch jobs without approval.

  1. 先探测再修改 — 在执行修剪、转码、拼接、音频提取、缩略图截取或GIF生成前,必须对每个源文件运行
    probe_media.py
    。使用探测字段选择映射、编码格式和时长范围。详见
    references/probe-fields.md
  2. 默认禁止原地覆盖 — 始终写入新输出路径。原地替换需用户明确批准,并执行备份/临时文件替换流程。详见
    references/safety.md
  3. 仅使用预设方案修改 — 仅从
    references/recipes-trim-transcode.md
    references/recipes-thumbnail-gif.md
    构建ffmpeg命令。未经批准不得使用临时滤镜链或破坏性批量任务。

Prerequisite Protocol

前置检查流程

Run before any mutation:
bash
uv run python scripts/doctor.py --format json
Stop when JSON
ok
is false. Install guidance:
bash
brew install ffmpeg
For each input file:
bash
uv run python scripts/probe_media.py /absolute/path/to/input.mp4
Parse
summary.duration_seconds
,
summary.stream_counts
, and codec fields before selecting a recipe.

执行任何修改操作前需运行:
bash
uv run python scripts/doctor.py --format json
若JSON返回
ok
false
则终止操作。安装指引:
bash
brew install ffmpeg
对每个输入文件执行:
bash
uv run python scripts/probe_media.py /absolute/path/to/input.mp4
在选择方案前解析
summary.duration_seconds
summary.stream_counts
和编码格式字段。

Mode Protocols

各模式执行流程

Doctor

环境检查

  1. Run
    uv run python scripts/doctor.py --format json
    .
  2. Report
    checks
    statuses and remediation for any
    fail
    .
  3. Do not run ffmpeg mutations when
    ffmpeg-binary
    or
    ffprobe-binary
    fails.
  1. 运行
    uv run python scripts/doctor.py --format json
  2. 报告
    checks
    状态,并为任何
    fail
    项提供修复方案
  3. ffmpeg-binary
    ffprobe-binary
    检查失败,不得执行ffmpeg修改操作

Probe

文件探测

  1. Require a readable local file path.
  2. Run
    uv run python scripts/probe_media.py <path>
    .
  3. Summarize: container, duration, video/audio codecs, resolution, stream counts.
  4. Load
    references/probe-fields.md
    when interpreting rotation, multi-track audio, or subtitle streams.
  1. 要求提供可读取的本地文件路径
  2. 运行
    uv run python scripts/probe_media.py <path>
  3. 汇总信息:容器格式、时长、视频/音频编码、分辨率、流数量
  4. 解读旋转角度、多轨音频或字幕流时,加载
    references/probe-fields.md

Trim

视频修剪

  1. Probe source; validate
    start
    /
    end
    against
    duration_seconds
    .
  2. Prefer stream copy when keyframe alignment is acceptable; otherwise use re-encode trim recipe.
  3. Output to
    basename.trim.ext
    or user-provided new path.
  4. Load
    references/recipes-trim-transcode.md
    .
  1. 探测源文件;验证
    start
    /
    end
    是否在
    duration_seconds
    范围内
  2. 若关键帧对齐可接受,优先使用流复制;否则使用重新编码修剪方案
  3. 输出至
    basename.trim.ext
    或用户指定的路径
  4. 加载
    references/recipes-trim-transcode.md

Transcode

格式转码

  1. Probe source; decide copy vs H.264/AAC re-encode.
  2. Map explicit streams when multiple tracks exist.
  3. Include
    -movflags +faststart
    for MP4 web delivery unless user forbids.
  4. Load
    references/recipes-trim-transcode.md
    .
  1. 探测源文件;决定使用直接复制还是H.264/AAC重新编码
  2. 存在多轨时明确映射流
  3. 除非用户禁止,否则MP4格式需添加
    -movflags +faststart
    参数以适配网页分发
  4. 加载
    references/recipes-trim-transcode.md

Concat

文件拼接

  1. Probe every segment; confirm compatible codecs/resolution for copy concat.
  2. Build concat list file with absolute paths; never concat unrelated codecs with copy without warning.
  3. Output to a new
    *.concat.mp4
    path.
  4. Load
    references/recipes-trim-transcode.md
    .
  1. 探测所有片段;确认编码/分辨率兼容以使用直接复制拼接
  2. 使用绝对路径构建拼接列表文件;未警告情况下不得直接复制拼接不兼容编码的文件
  3. 输出至新的
    *.concat.mp4
    路径
  4. 加载
    references/recipes-trim-transcode.md

Extract audio

音频提取

  1. Probe source; fail gracefully when
    stream_counts.audio
    is zero.
  2. Choose MP3, M4A, or copy recipe based on target format.
  3. Write
    basename.audio.ext
    as a new file.
  4. Load
    references/recipes-trim-transcode.md
    .
  1. 探测源文件;若
    stream_counts.audio
    为0则优雅终止
  2. 根据目标格式选择MP3、M4A或直接复制方案
  3. 将文件写入
    basename.audio.ext
    新文件
  4. 加载
    references/recipes-trim-transcode.md

Thumbnail

缩略图截取

  1. Probe source; require at least one video stream.
  2. Pick timestamp (user value, or 10% duration clamped 1–10s).
  3. Write JPG/PNG under
    OUTPUT/
    or sibling path — never overwrite source.
  4. Load
    references/recipes-thumbnail-gif.md
    .
  1. 探测源文件;要求至少包含一条视频流
  2. 选择时间戳(用户指定值,或时长的10%,限制在1-10秒之间)
  3. 将JPG/PNG写入
    OUTPUT/
    目录或同级路径 — 不得覆盖源文件
  4. 加载
    references/recipes-thumbnail-gif.md

GIF

GIF生成

  1. Probe source; cap duration (default max 5s unless user expands).
  2. Use two-pass palette recipe for quality; single-pass only for quick previews.
  3. Write
    clip.gif
    and optional
    palette.png
    as new files.
  4. Load
    references/recipes-thumbnail-gif.md
    .
  1. 探测源文件;限制时长(默认最大5秒,用户可扩展)
  2. 使用双-pass调色板方案保证质量;仅快速预览时使用单-pass
  3. clip.gif
    和可选的
    palette.png
    写入新文件
  4. 加载
    references/recipes-thumbnail-gif.md

Help (empty)

帮助 (空参数)

Show dispatch table, critical rules, doctor/probe commands, reference index, and the gallery below.
显示调度表、核心规则、环境检查/文件探测命令、参考文档索引及下方示例库

Gallery (Empty Arguments)

示例库(空参数时展示)

Present common local media tasks when
$ARGUMENTS
is empty:
#TaskExample
1Preflight tooling
/ffmpeg doctor
2Inspect metadata
/ffmpeg probe ~/Movies/clip.mp4
3Trim a clip
/ffmpeg trim ~/Movies/clip.mp4 00:00:05 00:00:15
4Transcode container
/ffmpeg transcode ~/Movies/clip.mov
5Join segments
/ffmpeg concat part1.mp4 part2.mp4
6Extract audio
/ffmpeg extract-audio ~/Movies/clip.mp4
7Poster frame
/ffmpeg thumbnail ~/Movies/clip.mp4 00:00:03
8GIF preview
/ffmpeg gif ~/Movies/clip.mp4 00:00:02 4
Pick a number, a mode from the dispatch table, or paste a file path and describe the edit.

$ARGUMENTS
为空时,展示常见本地媒体任务:
序号任务示例
1工具预检查
/ffmpeg doctor
2查看元数据
/ffmpeg probe ~/Movies/clip.mp4
3修剪视频片段
/ffmpeg trim ~/Movies/clip.mp4 00:00:05 00:00:15
4转码容器格式
/ffmpeg transcode ~/Movies/clip.mov
5合并视频段
/ffmpeg concat part1.mp4 part2.mp4
6提取音频
/ffmpeg extract-audio ~/Movies/clip.mp4
7截取海报帧
/ffmpeg thumbnail ~/Movies/clip.mp4 00:00:03
8生成GIF预览
/ffmpeg gif ~/Movies/clip.mp4 00:00:02 4
选择序号、调度表中的模式,或粘贴文件路径并描述编辑需求。

Skill Awareness

技能适用范围

SignalRedirect
"generate an image", "txt2img", "AI video", local Draw Things
draw-thing
"design a landing page", "Figma", "React layout"
design
"download from YouTube/URL"
yt-dlp
Live streaming, RTMP, OBS wiringout of scope — suggest streaming docs

需求信号引导至
"生成图像"、"txt2img"、"AI视频"、本地Draw Things
draw-thing
"设计落地页"、"Figma"、"React布局"
design
"从YouTube/URL下载"
yt-dlp
直播、RTMP、OBS配置超出范围 — 建议查看流媒体文档

Reference Files

参考文件

FileLoad when
references/safety.md
Any mutation; in-place overwrite questions
references/probe-fields.md
Interpreting probe JSON
references/recipes-trim-transcode.md
trim, transcode, concat, extract-audio
references/recipes-thumbnail-gif.md
thumbnail, gif

文件加载场景
references/safety.md
任何修改操作;原地覆盖相关问题
references/probe-fields.md
解读探测JSON结果
references/recipes-trim-transcode.md
修剪、转码、拼接、音频提取
references/recipes-thumbnail-gif.md
缩略图截取、GIF生成

Scripts

脚本工具

ScriptPurpose
scripts/doctor.py
Verify ffmpeg/ffprobe on PATH (
--format json
)
scripts/probe_media.py
ffprobe wrapper with summary (
--raw
for full payload)
scripts/check.py
Validate SKILL.md, evals, package dry-run, audit
Validation:
bash
uv run python scripts/check.py

脚本用途
scripts/doctor.py
验证PATH中的ffmpeg/ffprobe(
--format json
参数)
scripts/probe_media.py
ffprobe包装工具,生成汇总信息(
--raw
参数获取完整数据)
scripts/check.py
验证SKILL.md、评估、包预运行、审计
验证命令:
bash
uv run python scripts/check.py

Reporting Template

结果报告模板

After any mutation, report:
  1. Doctor status (if run this session)
  2. Probe summary (duration, codecs, streams)
  3. Recipe name (copy vs re-encode)
  4. Exact ffmpeg command(s) executed
  5. Output path(s) and size change
  6. Caveats (keyframe trim, missing audio, GIF duration cap)
执行任何修改操作后,需报告:
  1. 本次会话的环境检查状态
  2. 文件探测汇总(时长、编码格式、流信息)
  3. 使用的方案名称(复制或重新编码)
  4. 执行的完整ffmpeg命令
  5. 输出路径及文件大小变化
  6. 注意事项(关键帧修剪、缺失音频、GIF时长限制)