agentleFS
phanghonghaophanghonghao/THU-Awesome-Skills/skills/merge/SKILL.md

merge

Skill8 starsChanged 3 months agoMITView on GitHub

Merge multiple videos into a single grid video. Supports custom NxM layouts, labels, loop-to-longest duration, and streaming mode for large grids. Use when user mentions "merge videos", "合并视频", "拼视频", "视频对比", "video grid", "视频拼接", "compare videos", or "side by side video".

  • Installs packages

54 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use addskill, apply-firmware and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • ryanportfolioSkill

    addskill

    Create, import, update, or install repo or personal skills: runtime ownership, resources, discovery checks.

    Also in 6 projects that use this

  • ryanportfolioSkill

    apply-firmware

    Bring current folder (plain folder, existing repo, old or partial firmware copy) up to full Harness Firmware in place. Mirror external repo → adopt-repo.

    Also in 6 projects that use this

  • +10 more from ryanportfolio

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 1 is distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 48 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    After syncing to Claude with codex2claude, use the copied script in Claude's merge skill directory.

    line 18
  2. Very specific:

    Do not generate temporary merge scripts: Always call this permanent script directly with python.

    line 21
  3. Very specific:

    Use --loop-to-longest when the user wants the longest video to define the full episode and shorter videos to replay.

    line 47
  4. Very specific:

    Use --stream for large grids or long videos so encoded frames are written incrementally instead of held in memory.

    line 48
  5. Distinctive:

    Run the permanent script directly:

    line 49
  6. Very specific:

    All videos are resized to the smallest common resolution unless --cell-width or --cell-height caps the cell size.

    line 112

“Common” is measured: kept by at least 6 in 10 of the 48 edited versions of this file we could read. “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

Merge Videos

Merge multiple MP4 videos into a single grid-layout video with optional labels.

Permanent Script

The merge tool is the permanent CLI script next to this file:

<this skill directory>\merge_videos.py

After syncing to Claude with codex2claude, use the copied script in Claude's merge skill directory. Do not use hardcoded stale paths such as .claude-key3.

Do not generate temporary merge scripts. Always call this permanent script directly with python.

Templates

TemplateLayoutVideo CountDescription
2x12 rows, 1 col2Vertical stack of 2 videos
3x13 rows, 1 col3Vertical stack of 3 videos
2x22 rows, 2 cols4Square grid, TL TR BL BR
3x23 rows, 2 cols6Tall grid, 6 cells
NxMN rows, M colsN*MAny arbitrary grid, auto-parsed

Auto-detect template when -t is omitted:

  • 2 videos -> 2x1
  • 3 videos -> 3x1
  • 4 videos -> 2x2
  • 6 videos -> 3x2

For any other count, pass -t, for example -t 8x4 for 32 videos.

Workflow

  1. Find video paths from user arguments, globbing a directory when needed.
  2. Determine the template from the user request or by auto-detect.
  3. Auto-generate labels from filenames unless custom labels or --no-labels are requested.
  4. Use --loop-to-longest when the user wants the longest video to define the full episode and shorter videos to replay.
  5. Use --stream for large grids or long videos so encoded frames are written incrementally instead of held in memory.
  6. Run the permanent script directly:
python "<this skill directory>\merge_videos.py" <video_paths> -t <template> --labels <labels...> -o <output>
  1. Report output path, frame count, duration, resolution, and file size.

CLI Parameters

python merge_videos.py VIDEO [VIDEO ...] [-t TEMPLATE] [--labels LABEL [LABEL ...]]
                       [-o OUTPUT] [--gap N] [--fps N] [--font-size N] [--no-labels]
                       [--loop-to-longest] [--stream]
                       [--cell-width N] [--cell-height N]
ParameterDescriptionDefault
videosInput video file pathsRequired
-t, --templateLayout: 2x1, 3x1, 2x2, 3x2, or custom NxMAuto-detect from count
--labelsCustom label for each cellAuto from filenames
-o, --outputOutput file path<first_video_dir>/merge_<template>.mp4
--gapPixel gap between cells4
--fpsOutput frame rate30
--font-sizeLabel font size20
--no-labelsSkip cell labelsOff
--loop-to-longestUse the longest input duration; shorter videos loop from frame 0Off
--streamStream encoded output frames; required for large grids/long videosOff
--cell-widthMaximum output width per grid cell, preserving aspect ratioNone
--cell-heightMaximum output height per grid cell, preserving aspect ratioNone

Examples

2x2 grid:

python "<this skill directory>\merge_videos.py" `
  "dir\v1.mp4" "dir\v2.mp4" "dir\v3.mp4" "dir\v4.mp4" `
  -t 2x2 --labels "iter 1700" "iter 3000" "iter 5000" "iter 7000" `
  -o "dir\merge_2x2.mp4"

3x1 vertical:

python "<this skill directory>\merge_videos.py" `
  "dir\v1.mp4" "dir\v2.mp4" "dir\v3.mp4" `
  -t 3x1 --labels "IsaacLab" "MuJoCo Humanoid" "MuJoCo Manual"

Large 8x4 grid, longest video defines duration, shorter videos loop:

python "<this skill directory>\merge_videos.py" <32 videos> `
  -t 8x4 --loop-to-longest --stream --fps 50 `
  --cell-width 320 --cell-height 180 `
  -o "merge_8x4_loop_longest.mp4"

Notes

  • The script supports arbitrary NxM templates via auto-parsing.
  • All videos are resized to the smallest common resolution unless --cell-width or --cell-height caps the cell size.
  • Without --loop-to-longest, videos are cropped to the shortest input duration.
  • With --loop-to-longest, the output frame count equals the longest input frame count and shorter videos repeat.
  • For high video counts, always prefer --stream.

Prerequisites

Python packages:

pip install opencv-python imageio imageio-ffmpeg av Pillow numpy

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.