agentleFS
timelapsetechtimelapsetech/mediaskills/.agents/skills/video-transformation/SKILL.md

video-transformation

Skill1 starsChanged 3 months agoMITView on GitHub

Transform video with ffmpeg — trim, concatenate, transcode, scale, proxy, extract frames and audio, create GIFs, replace audio tracks, and other stream manipulation. Use when changing video files through editing cuts, codec conversion, resizing, muxing, or derivative exports.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If your tools showed a filesystem path when loading this SKILL.md, strip SKILL.md and use that folder.

    line 61
  2. Very specific:

    If you already ran another mediaskills script (for example .../audio/scripts/extract.py), this skill is a sibling of that folder: same …

    line 62
  3. Very specific:

    Prefer absolute paths for --input / --output when cwd is uncertain.

    line 85
  4. Distinctive:

    Before running any script, treat these two failures differently:

    line 90
  5. Very specific:

    Only escalate sandbox permissions if the error is explicitly a permission denial (e.g.

    line 93
  6. Very specific:

    Use output_path from the JSON result for the next step.

    line 103
  7. Distinctive:

    When video and audio live in different files (e.g.

    line 124
  8. Very specific:

    Do not use transcode.py for external audio — it only re-encodes a single file's streams.

    line 130
  9. Very specific:

    Read-only metadata (use inspect)

    line 180

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Video Transformation

ffmpeg-based video operations: editorial cuts, transcoding, scaling, muxing, and derivative exports. Outputs land in the workspace root .mediaskills/generated/ unless you pass --output. Override base path with $MEDIASKILLS_DATA_DIR.

When to use

  • This skill — trim, concat, transcode, scale, proxy, frame/audio extraction, GIF, replace audio, and similar ffmpeg transformations.
  • inspect — read metadata first (duration, codecs) before choosing trim boundaries or transcode settings.
  • timecode — frame-accurate timecode math when working in HH:MM:SS:FF or HH:MM:SS;FF instead of seconds.
  • audio — normalize or process audio before replace_audio.py.
  • subtitles — mux soft subtitles without burning; use this skill when the container needs re-wrapping.

Choosing an operation

GoalScript
Cut a time rangetrim.py
Pull several ranges as separate filestrim_multi.py
Join clips end-to-endconcat.py
Change codec, bitrate, or containertranscode.py
Resize for delivery or downstream processingscale.py
Fast low-res copy for reviewproxy.py
Still at a timestampextract_frame.py
Audio-only exportextract_audio.py
Short animated previewto_gif.py
Swap in external audio (e.g. after loudnorm)replace_audio.py

Transcoding and editorial trims share the same toolchain — probe first, then pick copy vs re-encode based on whether you need frame-accurate cuts or a new codec.

Gotchas

  • Stream copy vs re-encode — trim.py and trim_multi.py try -c copy first (fast, lossless cuts on keyframes). If that fails, they fall back to H.264/AAC re-encode. Cuts may snap to nearest keyframe when copying.
  • Concat codec mismatch — concat.py also tries copy first; mixed codecs/resolutions trigger a re-encode fallback.
  • Replace audio length — -shortest ends when the shorter of video or audio ends. Trim or pad audio first if lengths must match exactly.
  • GIF size — to_gif.py caps width at 480px and 10 fps; long clips produce large files. Trim first for previews.
  • Transcode codec strings — pass codec and bitrate separately (--codec libx264 --bitrate 1M). The script normalizes common agent mistakes like h264@1M.
  • Transcode vs replace audio — transcode.py re-encodes streams from a single input. Use replace_audio.py when audio comes from a separate file.

Running scripts

This skill's scripts live in scripts/ alongside this file. Before running any script, resolve its absolute path from this skill's own directory — do not assume the shell cwd is the skill folder, the repo root, or the workspace. Stay in the workspace (so media paths resolve) and pass the absolute script path to uv run:

uv run <skill_directory>/scripts/trim.py --input "<path-to-media>" --start 5 --end 12.5

<skill_directory> is a placeholder. Never pass those angle brackets to the shell — the command will fail. Replace it with a real absolute directory before invoking uv run.

How to get that directory (do this yourself; do not ask the user first; do not skip the skill):

  1. If your tools showed a filesystem path when loading this SKILL.md, strip SKILL.md and use that folder.
  2. If you already ran another mediaskills script (for example .../audio/scripts/extract.py), this skill is a sibling of that folder: same parent, directory name video-transformation.
  3. Otherwise search standard install locations and confirm the script exists:
NAME=video-transformation
for d in \
  "$HOME/.agents/skills/$NAME" \
  "$HOME/.cursor/skills/$NAME" \
  "$HOME/.codex/skills/$NAME" \
  "$HOME/.claude/skills/$NAME" \
  "$PWD/.agents/skills/$NAME" \
  "$PWD/.cursor/skills/$NAME" \
  "$PWD/skills/$NAME"
do
  if [ -f "$d/SKILL.md" ] && [ -e "$d/scripts/trim.py" ]; then
    SKILL_DIR=$(cd "$d" && pwd)
    break
  fi
done
[ -n "$SKILL_DIR" ] || { echo "mediaskills: $NAME not found" >&2; exit 1; }
uv run "$SKILL_DIR/scripts/trim.py" --input "<path-to-media>" --start 5 --end 12.5

Prefer absolute paths for --input / --output when cwd is uncertain.

Missing binaries vs permissions

Before running any script, treat these two failures differently:

  • If a required binary (uv, ffmpeg, ffprobe) reports No such file or directory or command not found: this is a missing or unreachable binary, not a permissions issue. Escalating sandbox permissions will not fix it. Run command -v uv, command -v ffmpeg, and command -v ffprobe to see whether they resolve at all. If not, install or re-link them (install-media-tools doctor/install) rather than retrying with wider permissions.
  • Only escalate sandbox permissions if the error is explicitly a permission denial (e.g. Operation not permitted, Permission denied).

Recipes

Trim a section

uv run <skill_directory>/scripts/trim.py --input /path/to/clip.mp4 --start 5 --end 12.5

Use output_path from the JSON result for the next step.

Cut several segments then join

  1. trim_multi.py with segments → returns segment_paths (real files like clip_segment_0.mp4).
  2. concat.py --paths with those exact paths from step 1. Never invent filenames.
  3. Report the concat output_path from the result.
uv run <skill_directory>/scripts/trim_multi.py --input clip.mp4 --segment 0:3 --segment 5:8
uv run <skill_directory>/scripts/concat.py --paths .mediaskills/generated/clip_segment_0.mp4 .mediaskills/generated/clip_segment_1.mp4

Transcode for delivery

uv run <skill_directory>/scripts/transcode.py --input master.mov --codec libx264 --bitrate 5M --output deliverable.mp4

Replace audio track

When video and audio live in different files (e.g. after audio normalization):

uv run <skill_directory>/scripts/replace_audio.py --input video.mp4 --audio normalized.wav --copy-video

Do not use transcode.py for external audio — it only re-encodes a single file's streams.

Trim then transcode

  1. trim.py → note output_path.
  2. transcode.py --input <trim output> --codec libx264 --bitrate 2M.

Low-res proxy for review

uv run <skill_directory>/scripts/proxy.py --input master.mp4

640px wide, ultrafast x264, CRF 28.

Troubleshooting

Error / symptomLikely causeAction
ffmpeg not foundBinary missingRun install-media-tools
Trim has frozen frame at startCut between keyframes with stream copyRe-run with --reencode
Concat fails then succeedsCodec/resolution mismatchFallback re-encode ran; check quality
Empty GIFVery short or corrupt inputProbe with inspect first
Replace audio too shortAudio shorter than video-shortest trimmed video; extend audio
Transcode larger than sourceHigh bitrate or lossless settingsLower --bitrate or raise --crf

Available scripts

ScriptPurpose
scripts/trim.pyCut a single time range
scripts/trim_multi.pyExtract multiple ranges to separate files
scripts/concat.pyJoin files end-to-end
scripts/transcode.pyRe-encode video + its own audio
scripts/replace_audio.pyMux video from one file with audio from another
scripts/scale.pyResize (--height -2 keeps aspect)
scripts/proxy.pyFast low-res review copy
scripts/extract_frame.pyStill image at timestamp
scripts/extract_audio.pyAudio track to MP3
scripts/to_gif.pyShort animated GIF

Acceptance checks (agent must pass before delivery)

  1. Contract: exit 0, ok: true, every output_paths entry exists and is non-empty.
  2. Probe: inspect.describe / compare on each media output — duration, codec, resolution, and streams match the request.
  3. Spot-check: open or sample the deliverable (trim window correct, scale dimensions, audio present after mux).
  4. On failure: fix flags and retry; do not present unprobed transforms as done.

Do not use for

  • Read-only metadata (use inspect)
  • Audio-only pipelines (use audio)
  • Caption/subtitle authoring (use speech-captions / subtitles)

Related skills

  • inspect — probe before transforming
  • timecode — timecode conversions
  • audio — process audio before muxing
  • subtitles — soft-subtitle mux workflows
  • install-media-tools — install ffmpeg

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.