Skip to content

Code Lab

ffmpeg-skill Explained: Turn Coding Agents into Local Video Editors

By Miles Park·
GitHub preview of kajisho5/ffmpeg-skill, Local FFmpeg editing, review pages, and machine-readable results.

CODE LAB · PROJECT SPOTLIGHT

ffmpeg-skill MIT

Local FFmpeg editing, review pages, and machine-readable results.

Preview: GitHub · kajisho5/ffmpeg-skill

A request such as “make a captioned vertical cut of this clip” contains several editing decisions. The video must fit a phone screen, the words must remain readable, and the audio must keep its timing. ffmpeg-skill gives coding agents a collection of local FFmpeg tools and a structured way to inspect their results. The interesting part for a reader is the connection between a request, the exact command, and the delivered frame.

Read the creator’s before-and-after example

Creator comparison of a basketball clip before and after adding readable outlined captions.
A still from kajisho5’s public caption demonstration. The original frame and captioned frame are shown side by side. This is the creator’s example. Creator image source.

Compare the lower center of the two frames. The right-hand version adds bold text with an outline so it remains readable against the court. That is a useful editing result to examine at phone size. Caption appearance alone does not establish that the words or timings are correct. Review the transcript and the frames where each caption begins and ends. Explore the creator’s demo files.

Start with one clip and one delivery format

Install FFmpeg and ensure both ffmpeg and ffprobe are available in the terminal used by your agent. The project’s npm launcher exposes the editing tools. Start with a copy of a clip and ask the agent to preserve the original, describe the planned crop, and show a review page after processing. The following commands are a reader workflow from the documented tool interface. We inspected their source and calculated the crop geometry locally. We did not encode a video in this check.

npx ffmpeg-skill fit.py input.mp4 --aspect 9:16 --fit pad --width 1080
# Keep the entire picture inside a vertical frame.

npx ffmpeg-skill fit.py input.mp4 --aspect 9:16 --fit crop --width 1080
# Fill the frame. Review who or what the crop removes.

For a 1,920 × 1,080 source, a 9:16 crop at the original height retains about 607.5 pixels of the width before encoder rounding. That is 31.64% of the original width. A person at the edge of a two-person interview can disappear. Padding retains both people but makes the central picture smaller. Choose based on what the scene needs.

source_width, source_height = 1920, 1080
kept_width = source_height * 9 / 16
print(f"{kept_width:.1f} pixels; {100 * kept_width / source_width:.2f}%")
# Observed local output
# 607.5 pixels; 31.64%

What the actual crop code checks

kajisho5/ffmpeg-skillPython · source excerpt
Py  scripts/fit.py
424    # the box is in the displayed frame cropdetect.py reports: rotation applied, and a425    # non-square-pixel source squared at its display aspect first (#411)426    sw, sh = display_size(meta["video"])427    x, y = (x, y) if x is not None else ((sw - w) // 2, (sh - h) // 2)428    if x < 0 or y < 0 or x + w > sw or y + h > sh:429        die(f"crop rectangle ({x},{y},{w}x{h}) exceeds the source frame ({sw}x{sh})")430    output = args.output or default_output(args.input, suffix)431    # exact=1: without it crop rounds an odd x/y down to the chroma grid of a 4:2:0 frame, and the432    # rectangle written was one pixel left of / above the one asked for (A170's sibling, A157)433    vf = [f"crop={w}:{h}:{x}:{y}:exact=1", "setsar=1"]
Lines 424–433 · commit e1276f1View original on GitHub ↗

Source credit: kajisho5/ffmpeg-skill. MIT license and copyright notices.

This excerpt belongs to the explicit –rect path. It calculates the displayed source size, centers a box when coordinates are omitted, refuses rectangles outside the image, and builds an exact FFmpeg crop filter. The exact=1 flag preserves an odd coordinate instead of silently shifting it to the chroma grid. The aspect-ratio workflow above chooses its own crop dimensions, while this branch is useful when an editor already knows the box to keep.

Use the review page to judge the result

The repository documents a review command that builds a local HTML page from the project and result records. Ask the agent to show the sources, output, checks, and warnings there. Confirm the dimensions and duration, then inspect the first frame, the busiest caption, and a frame with a subject near the edge. A successful encode can still need an editorial correction. Creator demos and videos remain external links in this article. Review-page documentation.

For selecting moments from long footage, continue with AutoClip and subtitle timing. For transcript-driven edits, see video-use’s timeline workflow. To turn a reference into a production plan, read REA Video shot analysis.

Discussion

Join the discussion

Your email address will not be published. Required fields are marked *