Communitygithub.com

jingke/footage-to-short-video

把一批视频素材(DJI 无人机、相机、手机拍摄的旅拍/活动/探店 B-roll)剪辑成可发布的短视频成片——裁切画幅、生成中文字幕、配 BGM、做封面、校准码率与响度,输出竖屏 9:16 与横屏 16:9 双版本。当用户提供多个视频文件并要求「剪一个短视频」「做成视频号/抖音能发的片子」「加字幕配 BGM」「把这段素材剪出来」时应使用本技能。

footage-to-short-video 是什么?

footage-to-short-video is a Claude Code agent skill that 把一批视频素材(DJI 无人机、相机、手机拍摄的旅拍/活动/探店 B-roll)剪辑成可发布的短视频成片——裁切画幅、生成中文字幕、配 BGM、做封面、校准码率与响度,输出竖屏 9:16 与横屏 16:9 双版本。当用户提供多个视频文件并要求「剪一个短视频」「做成视频号/抖音能发的片子」「加字幕配 BGM」「把这段素材剪出来」时应使用本技能。.

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/jingke/footage-to-short-video/tree/HEAD/skills-footage-to-short-video

在你喜欢的 AI 中提问

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

文档

Footage-to-Short-Video Pipeline

Overview

Turn a pile of raw footage into instantly publishable short videos. The entire process runs locally, no GUI software like CapCut required, and no API keys needed.

Core capabilities: Probe footage → extract frames to understand content → crop aspect ratio → render subtitles with PIL (bypassing ffmpeg's missing libass issue) → cross-dissolve stitching → pick BGM and calibrate loudness → generate cover.

Preflight Check

Run the environment self-check before starting (it will output installation commands for missing dependencies):

python3 scripts/check_env.py

Requires ffmpeg / ffprobe and Python 3 + Pillow; everything else uses only the standard library (no numpy dependency). Full installation steps, cross-platform font handling, and common issues for each platform can be found in references/setup.md.

About Subtitles: Two Paths, Choose as Needed

ScenarioWhat to UseDescription
Few refined text cards (default)PIL-rendered transparent layer + overlayNo dependency on ffmpeg compile options, flexible layout
Dozens/hundreds of dialogue subtitlesffmpeg with libassOne subtitle file for the whole film, -vf "ass=sub.ass"

This machine already has a self-built ffmpeg with libass at ~/.workbuddy/bin/ffmpeg (build process and verification commands in references/ffmpeg-with-libass.md). Do not replace PATH with it by default—it lacks external libraries like libvpx / x265 / dav1d; it is not a superset of the system ffmpeg. Call it explicitly when needed or temporarily export PATH="$HOME/.workbuddy/bin:$PATH".

Workflow

Step 0: Confirm Three Things (Use AskUserQuestion, Don't Guess)

QuestionOptions
Aspect ratioVertical 9:16 (recommended for feeds) / Horizontal 16:9 / Both
Duration~30s (quick edit) / ~60s (recommended) / ~90s
BGMUser provides file / Find CC0 free tracks online / Output without music first

Get answers before starting. If user does not specify, default to vertical + 60s + find CC0 tracks online.

Step 1: Probe Footage

python scripts/probe_footage.py <footage_directory> --ext .MP4

Get each clip's resolution, frame rate, duration, file size, and total duration. When resolutions are not uniform, you must specify crop parameters per clip later.

⚠️ Large File Warning: Any single file with size ≥ 2GB or duration ≥ 300s will be marked with 🔴 in the table, and the script will print a prominent warning block at the end (listing files + cumulative size + handling suggestions). Directly decoding/analyzing/splitting such footage may take tens of minutes or even time out (for long clips, never use fps+tile full decode; see references/pitfalls.md). When you see this warning, go to Step 1.5 first.

Step 1.5: Large File Manual Confirmation (Only Needed When 🔴 Appears)

When Step 1 marks large files, before running Step 2 (frame extraction) / analysis / Step 4 (clip cutting), you must use AskUserQuestion to get user confirmation; do not assume you can decode several GB/hundreds of seconds of footage in one go. Give the user three options:

OptionMeaning
Confirm and continueUser is aware of the time cost; proceed directly (subsequent commands can use --confirm to suppress prompts)
Extract a sample firstUse contact_sheet.py --ss <seconds> to grab a few frames at specific points to verify content, then decide
Skip this fileRemove this clip from the footage list; do not include it in the final video

Only proceed if the user selects "Confirm and continue"; if "Skip", modify the config to remove that clip.

Step 2: Extract Frames to See Content (Cannot Be Skipped)

python scripts/contact_sheet.py <footage_directory> --out sheet.jpg --per 3

You must look at the images before writing subtitle text—guessing based on file names is almost always wrong. Read the generated contact sheet directly and review each clip sequentially.

If converting to vertical, also verify the crop window:

python scripts/contact_sheet.py <footage_directory> --out sheet.jpg \
    --crop 9:16 --crop-x 1100 1312 1500 --src-w 3840

The green/red/blue boxes are three candidate crop positions. After confirming the subject (especially faces) is within the box, write the selected value into crop_x in the config.

Step 3: Write Configuration File

Copy assets/project_config.example.json to the working directory and modify it. Field descriptions are in the template comments.

Key fields:

  • clips[] — Each clip has ss (start), dur (duration), optional crop_x / crop_y
    • motion label (optional): "pan" / "push" (forward motion/push-in), "orbit" (circular motion). Used as signposts for transitions:"auto"—auto will replace the corresponding cut point with smoothleft / circleopen accordingly.
    • reveal (optional, boolean): If the next clip is a "reveal wide shot", auto will use smoothleft to pan horizontally at the entry point.
    • kenburns (optional): Keyframe push/pull (ffmpeg equivalent of CapCut's "keyframes", implemented with zoompan). Write true for a default slow zoom-in from 1.0→1.15; or write an object like {"zoom":1.2,"dir":"in|out","pan":"center|left|right|up|down"}. Recommended zoom ≤1.3; larger values cause more blur. Implementation oversamples first, then scales down, always sampling within the frame so no black edges appear.
  • transitions — Optional, two ways to specify:
    • Write "auto" (recommended): Script picks appropriate transitions based on each clip's motion / reveal labels, and ensures not all are fade (when all are fade, inject smoothleft at roughly 1/3 of the cuts).
    • Write a list (length = number of clips − 1): Manually specify per cut. Available transitions: fade (cross-dissolve, safest), smoothleft / smoothright (horizontal slide, matches "moving forward"), slideleft / slideup, circleopen / circleclose (circular expand/close, matches orbiting), radial, distance, fadeblack. Using only one transition throughout can feel monotonous; even with manual specification, it's recommended to use mainly fade and swap in 2–4 directional transitions at semantic turning points.
  • xfade_dur[] — Optional, per-cut transition duration (default 0.5~0.7s depending on transition type)
  • captions[] — Subtitle start / end / text; text within 【】 is automatically highlighted in gold
  • title — Main title and English subtitle
  • pips[] — Optional, picture-in-picture (ffmpeg equivalent of CapCut's "画中画"): Scales another clip into a small window, overlays it in a corner or center during a specified time range. Each item: {file, ss, dur, scale(default 0.3), corner(tl/tr/bl/br/center), margin(default 0.05), border(white border in pixels, optional), at:[start,end] seconds, animate:"drift"(optional slight drift)}.
  • vignette — Optional, vignette/mask effect (ffmpeg equivalent of CapCut's "蒙版/暗角"): Write an intensity value 0.10.5 (higher = darker, 0.20.3 is more natural), makes the center stand out and adds cinematic feel. Disabled by default. (Internally maps to the angle parameter of the vignette filter; lower value = deeper vignette.)

CapCut's native interactions for "keyframes / picture-in-picture / mask" are more detailed, but this skill provides equivalent capabilities via ffmpeg: Keyframe push/pull = kenburns (zoompan), picture-in-picture = pips[], mask/vignette = vignette. If further refinement is needed, the master video can be imported into CapCut for manual touch-ups, but the default pipeline already produces great results.

Timeline calculation: Total duration = Σdur − Σtransition durations. Subtitle timing is based on this timeline. See references/caption-writing.md for copywriting guidelines.

Step 4: Cut Clips

python scripts/cut_clips.py config.json

When aspect ratios match, only scaling is applied; when they differ, crops are performed to the target ratio (center-crop by default, overridden by crop_x).

Step 5: Generate Subtitle Layer

python scripts/make_captions.py config.json

Font size is calculated automatically based on aspect ratio (horizontal gets larger to avoid being too small on phones). Layout can be overridden with the layout field.

Step 6: Render Master

python scripts/render_master.py config.json

Outputs master_silent.mp4 (no audio track). Transitions (default auto-select) + subtitle overlay + picture-in-picture (if any)

  • vignette (if any) + fade in/out at start/end.

Must spot-check after rendering: Extract one frame every 4–6 seconds into a contact sheet, verify subtitle positions, transitions, picture-in-picture, and composition.

Step 7: Pick BGM

python scripts/pick_bgm.py --list --category travel      # List candidates
python scripts/pick_bgm.py --pick "Just Keep Walking" "Summer Fun" --out-dir bgm

The script fetches tracks from Mixkit (CC0, free for commercial use, no attribution required), downloads them, measures energy curves, and provides a recommendation ranking. Criteria: no blank start + low dynamic range. Choose based on the recommendation results, not by feeling the track name.

Write the selected result into the config's bgm field.

Step 8: Mix Audio

python scripts/mix_audio.py config.json

Uses -c:v copy to directly copy the video stream—fast and zero quality loss. The script automatically detects loudness and prompts if it deviates from the comfort zone (pure BGM target -17~-18 LUFS); if off, adjust volume_db and re-run.

Step 9: Create Cover

python scripts/make_cover.py config.json --out cover.jpg

Horizontal defaults to left layout (dark gradient on the left + left-aligned text, avoids subjects in the frame), vertical defaults to bottom layout. Cover background uses already-cut clips, does not re-read 4K source.

Step 10: Deliver

Use present_files to deliver the final video and cover, and include absolute paths in the reply.

When the user requests a second aspect ratio: Create a separate widescreen/ subdirectory, copy the config, modify variant / out_w / out_h, then re-run Steps 4–9. The vertical version remains untouched.

Step 11: Generate WeChat / Xiaohongshu Copy + Images (Optional, Highly Recommended)

After the video is done, create a set of social media copy and images, forming a complete "video + text" release package. Images are extracted from the final video (authentic, zero cost, consistent style); copy is written by the agent following references/social-copy.md in two different tones, each version for a different platform.

① Extract Still Frames (Image Material for Social)

python scripts/extract_stills.py <final_video.mp4> --out <work>/stills --count 9

Uniformly extract 9 high-quality still frames, and create a stills_sheet.jpg for choosing the cover. Safe for long videos (uses per-point -ss for fast seeking, no full decode).

② Pick a Cover Still: Read stills_sheet.jpg (already compressed to a viewable size), choose the one with the cleanest subject and most "cover-like" feel, record its path (e.g., stills/still_03.jpg).

③ Create Social Media Images

python scripts/make_social_assets.py stills/still_03.jpg \
    --title "Qingdao|A Thousand Miles of Coastline" --subtitle "A Mountain-Sea Ramble on a Rainy Day" \
    --font "<config.font>" --gold "<config.gold>" --out <work>/social

Outputs social/xhs_cover.jpg (Xiaohongshu 3:4 cover) + social/wechat_header.jpg (WeChat Official Account 2.35:1 header), both with bottom dark gradient + title/gold subtitle, readable on mobile.

④ Write Copy (agent executes, do not have a script write it): Following the templates in references/social-copy.md, read the narrative line from the final video's captions[], produce two .md files:

  • social/wechat_article.md —— WeChat long-form article (deep/story/warm, 800–1500 words)
  • social/xhs_post.md —— Xiaohongshu note (colloquial/emoji/bullet list, including 3–6 #hashtags)

The two tones are different (see template comparison table); do not repost the same paragraph with a different title on two platforms. cover.line1/line2 can serve as subtitle templates directly; subtitles with 【golden words】 can be used as quotes/tags.

⑤ Deliver: present_files the three files in social/ plus the two .md files together with the final video.

The config can include an optional social block to pre-fill copy templates, avoiding manual typing each time:

"social": {
  "title": "Qingdao|A Thousand Miles of Coastline",
  "subtitle": "A Mountain-Sea Ramble on a Rainy Day",
  "cover_still": "stills/still_03.jpg",
  "platforms": ["wechat", "xhs"],
  "still_count": 9
}

If cover_still is omitted, the agent reads the sheet and picks the best frame itself; if title is omitted, falls back to the video's title.main.

Key Reminders

  • Subtitle copy must be written after looking at the images; B-roll footage has no audio, speech recognition will return nothing
  • Crop positions must be verified per clip; center cropping often cuts off half a person's face
  • Loudness must be measured, not guessed from dB values; if below -20 LUFS, platforms will apply secondary gain causing clipping
  • Cover must be set manually; platform auto-frame grabs often capture random people's faces

For a full list of pitfalls, see references/pitfalls.md; platform specifications and directory conventions are in references/platform-specs.md; subtitle copywriting guidelines are in references/caption-writing.md.

Resources

scripts/

ScriptStepPurpose
check_env.py0Environment check: ffmpeg/filters/Pillow/fonts, provide installation commands for missing items
probe_footage.py1Probe footage specs, output table and total size assessment
contact_sheet.py2Extract frames into a contact sheet; can overlay crop window to verify subjects
cut_clips.py4Crop/scale footage into clips (supports kenburns keyframe push/pull)
make_captions.py5PIL-render transparent subtitle layer PNG
render_master.py6Auto transitions + subtitle overlay + picture-in-picture + vignette, output master without audio
pick_bgm.py7Fetch Mixkit CC0 candidates, measure energy curves, recommend
mix_audio.py8Mix BGM + loudness calibration + detection
make_cover.py9Generate cover (left / bottom two layouts)
extract_stills.py11Extract still frames from final video + cover candidate sheet (social media image material)
make_social_assets.py11PIL-compose Xiaohongshu cover (3:4) + WeChat Official Account header (2.35:1)

All scripts support python3 <script> --help or check the docstring at the top of the file for parameters.

references/

  • setup.md — Dependency installation guide (macOS / Linux / Windows, including self-check and common issues)
  • pitfalls.md — 8 tested pitfalls (missing subtitle filters, horizontal font size, cropping people, bitrate, loudness, etc.)
  • ffmpeg-with-libass.md — Build ffmpeg with libass/freetype from source (macOS complete recipe + pitfalls)
  • platform-specs.md — WeChat Video/TikTok specs, aspect ratio choices, delivery directory conventions
  • caption-writing.md — Subtitle copywriting guidelines, structural templates, timeline arrangement
  • social-copy.md — WeChat long-form article + Xiaohongshu note dual templates, tone differences, image layout, theme extraction

assets/

  • project_config.example.json — Project configuration template (includes a complete Qingdao Beer Museum example)

相关技能