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.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- site/AGENTS.mdAGENTS.md
- site/CLAUDE.mdCLAUDE.md
- audioSkill
- captions-complianceSkill
- downloadSkill
- forced-narrative-exactSkill
- imageSkill
- inspectSkill
- install-media-toolsSkill
- program-masterSkill
- shotsSkill
- speech-captionsSkill
- subtitlesSkill
- timecodeSkill
- vision-analysisSkill
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
- Very specific: line 61
If your tools showed a filesystem path when loading this SKILL.md, strip SKILL.md and use that folder.
- Very specific: line 62
If you already ran another mediaskills script (for example .../audio/scripts/extract.py), this skill is a sibling of that folder: same …
- Very specific: line 85
Prefer absolute paths for --input / --output when cwd is uncertain.
- Distinctive: line 90
Before running any script, treat these two failures differently:
- Very specific: line 93
Only escalate sandbox permissions if the error is explicitly a permission denial (e.g.
- Very specific: line 103
Use output_path from the JSON result for the next step.
- Distinctive: line 124
When video and audio live in different files (e.g.
- Very specific: line 130
Do not use transcode.py for external audio — it only re-encodes a single file's streams.
- Very specific: line 180
Read-only metadata (use inspect)
≈ “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.
Files
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 beforereplace_audio.py.subtitles— mux soft subtitles without burning; use this skill when the container needs re-wrapping.
Choosing an operation
| Goal | Script |
| Cut a time range | trim.py |
| Pull several ranges as separate files | trim_multi.py |
| Join clips end-to-end | concat.py |
| Change codec, bitrate, or container | transcode.py |
| Resize for delivery or downstream processing | scale.py |
| Fast low-res copy for review | proxy.py |
| Still at a timestamp | extract_frame.py |
| Audio-only export | extract_audio.py |
| Short animated preview | to_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.pyandtrim_multi.pytry-c copyfirst (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.pyalso tries copy first; mixed codecs/resolutions trigger a re-encode fallback. - Replace audio length —
-shortestends when the shorter of video or audio ends. Trim or pad audio first if lengths must match exactly. - GIF size —
to_gif.pycaps width at 480px and 10 fps; long clips produce large files. Trim first for previews. - Transcode codec strings — pass
codecandbitrateseparately (--codec libx264 --bitrate 1M). The script normalizes common agent mistakes likeh264@1M. - Transcode vs replace audio —
transcode.pyre-encodes streams from a single input. Usereplace_audio.pywhen 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):
- If your tools showed a filesystem path when loading this
SKILL.md, stripSKILL.mdand use that folder. - If you already ran another mediaskills script (for example
.../audio/scripts/extract.py), this skill is a sibling of that folder: same parent, directory namevideo-transformation. - 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.5Prefer 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) reportsNo such file or directoryorcommand not found: this is a missing or unreachable binary, not a permissions issue. Escalating sandbox permissions will not fix it. Runcommand -v uv,command -v ffmpeg, andcommand -v ffprobeto see whether they resolve at all. If not, install or re-link them (install-media-toolsdoctor/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.5Use output_path from the JSON result for the next step.
Cut several segments then join
trim_multi.pywith segments → returnssegment_paths(real files likeclip_segment_0.mp4).concat.py --pathswith those exact paths from step 1. Never invent filenames.- Report the concat
output_pathfrom 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.mp4Transcode for delivery
uv run <skill_directory>/scripts/transcode.py --input master.mov --codec libx264 --bitrate 5M --output deliverable.mp4Replace 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-videoDo not use transcode.py for external audio — it only re-encodes a single file's streams.
Trim then transcode
trim.py→ noteoutput_path.transcode.py --input <trim output> --codec libx264 --bitrate 2M.
Low-res proxy for review
uv run <skill_directory>/scripts/proxy.py --input master.mp4640px wide, ultrafast x264, CRF 28.
Troubleshooting
| Error / symptom | Likely cause | Action |
ffmpeg not found | Binary missing | Run install-media-tools |
| Trim has frozen frame at start | Cut between keyframes with stream copy | Re-run with --reencode |
| Concat fails then succeeds | Codec/resolution mismatch | Fallback re-encode ran; check quality |
| Empty GIF | Very short or corrupt input | Probe with inspect first |
| Replace audio too short | Audio shorter than video | -shortest trimmed video; extend audio |
| Transcode larger than source | High bitrate or lossless settings | Lower --bitrate or raise --crf |
Available scripts
| Script | Purpose |
scripts/trim.py | Cut a single time range |
scripts/trim_multi.py | Extract multiple ranges to separate files |
scripts/concat.py | Join files end-to-end |
scripts/transcode.py | Re-encode video + its own audio |
scripts/replace_audio.py | Mux video from one file with audio from another |
scripts/scale.py | Resize (--height -2 keeps aspect) |
scripts/proxy.py | Fast low-res review copy |
scripts/extract_frame.py | Still image at timestamp |
scripts/extract_audio.py | Audio track to MP3 |
scripts/to_gif.py | Short animated GIF |
Acceptance checks (agent must pass before delivery)
- Contract: exit 0,
ok: true, everyoutput_pathsentry exists and is non-empty. - Probe:
inspect.describe/compareon each media output — duration, codec, resolution, and streams match the request. - Spot-check: open or sample the deliverable (trim window correct, scale dimensions, audio present after mux).
- 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 transformingtimecode— timecode conversionsaudio— process audio before muxingsubtitles— soft-subtitle mux workflowsinstall-media-tools— install ffmpeg
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
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.

