Skip to content
Cutfac

How to automate Shorts with Claude Code: one format, many videos

Making Shorts one at a time means doing the same work every time: crop the clip, place the caption, match the font and the color. This guide moves that work into a format, code that stays the same for every video, and keeps what changes, the episode, as data. It follows one real run: four city time-lapses go in, and one command renders four Shorts in the same format. Each step shows the command or code, what it printed, and what the tool behind it does.

Published:

BeforeAlbury and Hong Kong on top, Shanghai and Shibuya below: the four source clips, landscape and silent, each cut to the 15 seconds its Short uses. Albury's clip is shorter, so its last frame holds.
AfterLeft to right Albury, Hong Kong, Shanghai and Shibuya, each 1080 × 1920 and silent, shown side by side at a third of their size. Albury's video is shorter, so its last frame holds until the others end.

What we're making

The footage is four CC0 time-lapses from Wikimedia Commons: Dean Street in Albury, New South Wales, at night; Causeway Bay in Hong Kong from a rooftop; the Lujiazui skyline in Shanghai; and Shibuya Crossing in Tokyo, the same clip as the earlier guides. They don't match: two file types, three frame rates, two sizes, and 14 to 37 seconds long. None has sound.

The goal is one Short per city in one format, with the highlight captions from “How to make animated word-by-word captions with Remotion and Claude Code”: the whole line shows and the current word takes the city's color. The four finished videos are at the top of the page, under the four clips they came from.

Every command, output and frame below comes from that run, which made eight videos in all: the same four in English and Korean. This page shows the English ones.

What you need

Node.js, Claude Code signed in with your own account, and a folder with the four clips and the font file. Remotion renders the videos; two command-line tools, which Homebrew installs on a Mac, crop the clips and build the contact sheet:

brew install ffmpeg imagemagick
  • Claude Code: the agent. It writes the React files, runs Remotion's commands and looks at the frames they produce.
  • Remotion: a framework that turns React components into MP4 files. It renders each frame in a headless browser and encodes them with a bundled ffmpeg.
  • Remotion Agent Skills: instructions that teach Claude Code how to write Remotion code, such as how timing and captions work. They install into the project folder.
  • ffmpeg: converts video. Here it crops the clips and pulls the frames for the contact sheet.
  • ffprobe: reads a video file and reports what's in it, such as size, length and codecs. It comes with ffmpeg.
  • ImageMagick: draws images from the command line. Here it stacks the contact sheet's rows.
  • Zod: describes the shape of the props each video takes. Mediabunny: reads media files in JavaScript, used here for a clip's length.
  • Pretendard Bold (Pretendard-Bold.otf): the caption font, free under the SIL Open Font License.
  • Remotion has its own license, not an open-source one. It's free for individuals, non-profits and for-profit companies of up to three employees; larger companies need a company license.

Step 1: Create the project and add the skills

Remotion's project starter sets up a React app with one empty video. --blank skips the example animations and --yes accepts the defaults:

npx create-video@latest --yes --blank city-shortscd city-shorts

Next, the Agent Skills. The skills command copies 12 skill folders into .claude/skills, where Claude Code picks them up the next time it starts in this folder. It ends with a reminder to review skills before use, since they run with the agent's permissions; they're plain Markdown, so a quick read is easy.

npx skills add remotion-dev/skills -a claude-code -yls .claude/skills
remotion-best-practices  remotion-docs           remotion-markup      remotion-saas
remotion-captions        remotion-interactivity  remotion-multimedia  remotion-studio
remotion-create          remotion-maps           remotion-render      remotion-upgrade

Then the packages. @remotion/media plays the clip inside the video, @remotion/zod-types adds zColor, a color type for props, zod describes the props' shape, and mediabunny reads a clip's length:

npx remotion add @remotion/media @remotion/zod-types zodnpm i mediabunny

The four clips go in clips/ and the font in public/. Anything in public/ can be loaded from code with staticFile().

Step 2: Brief Claude Code

Open Claude Code in city-shorts. The brief asks for every video at once, and for the parts that change to live apart from the parts that don't:

Claude Code

clips/ has four silent city time-lapses: albury.webm, hongkong.ogv, shanghai.webm and shibuya.webm. Make one Short per city in one format with Remotion: - Crop each to 1080 × 1920 at 30 fps, at most 15 seconds, into public/ - Three lines of caption per video in Pretendard-Bold.otf; the whole line shows and the current word takes the episode's color - Keep captions clear of the bottom where the app's buttons sit - Captions in English and Korean: one JSON file per city in episodes/en and episodes/ko, and nothing city-specific in the component - Each video as long as its clip - One command renders every episode, then make a contact sheet so you can check them all

The brief splits the work in two: the format, one component every video shares, and the episodes, one JSON file per city with only what differs. The skills tell Claude Code how to build each part, so the brief only says what the video should be.

Step 3: Crop the clips

Claude Code started with the footage. Each clip becomes a vertical slice at 30 fps, one ffmpeg command per city:

ffmpeg -ss 18 -t 15 -i clips/shibuya.webm -vf "crop=ih*9/16:ih:450:0,scale=1080:1920,fps=30" -an -c:v libx264 -crf 20 -pix_fmt yuv420p public/shibuya.mp4ffmpeg -ss 4 -t 15 -i clips/hongkong.ogv -vf "crop=ih*9/16:ih:300:0,scale=1080:1920,fps=30" -an -c:v libx264 -crf 20 -pix_fmt yuv420p public/hongkong.mp4ffmpeg -ss 20 -t 15 -i clips/shanghai.webm -vf "crop=ih*9/16:ih:560:0,scale=1080:1920,fps=30" -an -c:v libx264 -crf 20 -pix_fmt yuv420p public/shanghai.mp4ffmpeg -i clips/albury.webm -vf "crop=ih*9/16:ih:480:0,scale=1080:1920,fps=30" -an -c:v libx264 -crf 20 -pix_fmt yuv420p public/albury.mp4

crop=ih*9/16:ih:x:0 keeps the full height and takes a width of 9/16 of it, starting x pixels from the left. As in the first guide, each x was picked by comparing four slices of one frame; Shibuya's 450 is the one from that guide. scale=1080:1920 sets the size, and fps=30 brings Albury's 25 and Shanghai's 29.97 to 30. -ss and -t keep 15 seconds; Albury's clip is under 14 seconds, so it's used whole. -an drops the audio, -crf 20 sets the quality and -pix_fmt yuv420p keeps the H.264 file playable everywhere.

Four vertical frames side by side: Albury's street at night lit orange, Hong Kong's Causeway Bay from a rooftop with trams, buses and billboards, Shanghai's Oriental Pearl Tower at blue hour, and Shibuya Crossing under a pink billboard.
One frame from each cropped clip, left to right Albury at 8 seconds, Hong Kong at 5, Shanghai at 4 and Shibuya at 5.

Then a check with ffprobe. -count_frames decodes and counts every frame, so the number is what's really in the file:

for f in public/*.mp4; do  echo $f $(ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=width,height,nb_read_frames:format=duration -of csv=p=0 $f | tr '\n' ' ')done
public/albury.mp4 1080,1920,413 13.766667
public/hongkong.mp4 1080,1920,450 15.000000
public/shanghai.mp4 1080,1920,450 15.000000
public/shibuya.mp4 1080,1920,450 15.000000

All four are 1080 × 1920. Albury is a little under 14 seconds, and the other three are 15.

Step 4: Episode data and schema

Each episode is a JSON file with the clip, the color and three lines, timed in seconds. This is Shibuya's:

{  "clip": "shibuya.mp4",  "color": "#FFD84D",  "lines": [    { "from": 0.6, "to": 2.8, "text": "Shibuya Crossing, Tokyo" },    { "from": 3.3, "to": 6.8, "text": "The cars stop, the crowd goes" },    { "from": 11.4, "to": 14.6, "text": "And here it comes again" }  ]}

src/City.tsx starts by describing that shape with Zod. Remotion Studio shows a schema's props as fields you can edit, and zColor makes the color a color picker:

import { Video } from "@remotion/media";import { zColor } from "@remotion/zod-types";import { ALL_FORMATS, Input, UrlSource } from "mediabunny";import {  AbsoluteFill,  type CalculateMetadataFunction,  Sequence,  continueRender,  delayRender,  staticFile,  useCurrentFrame,  useVideoConfig,} from "remotion";import { z } from "zod";// One episode. Everything that changes from one video to the next lives here.export const episodeSchema = z.object({  clip: z.string(),  color: zColor(),  lines: z.array(z.object({ from: z.number(), to: z.number(), text: z.string() })),});export type Episode = z.infer<typeof episodeSchema>;type Line = Episode["lines"][number];export const FPS = 30;// Each video is as long as its clip.export const calculateMetadata: CalculateMetadataFunction<Episode> = async ({ props }) => {  const input = new Input({ formats: ALL_FORMATS, source: new UrlSource(staticFile(props.clip)) });  const seconds = await input.computeDuration();  return { durationInFrames: Math.ceil(seconds * FPS) };};

calculateMetadata runs before the render and sets the video's length from the props: Mediabunny reads the clip's duration and Math.ceil turns it into whole frames, so Albury's video gets 413 frames, a little under 14 seconds, and the others about 15.

Step 5: The component

The rest of the file is the format: how a caption looks, when each word lights up and where the lines sit. Nothing about any city is in it:

const font = new FontFace("Pretendard", `url(${staticFile("Pretendard-Bold.otf")})`);const fontHandle = delayRender("Loading Pretendard");font.load().then(() => {  document.fonts.add(font);  continueRender(fontHandle);});const textStyle: React.CSSProperties = {  fontFamily: "Pretendard",  fontSize: 84,  lineHeight: 1.15,  color: "white",  textAlign: "center",  wordBreak: "keep-all",  textShadow: "0 4px 18px rgba(0,0,0,0.55)",};// Spread a line's words over its time. Longer words get more of it.const words = (line: Line) => {  const parts = line.text.split(" ");  const letters = parts.reduce((n, w) => n + w.length, 0);  let t = line.from;  return parts.map((w, i) => {    const from = t;    t += ((line.to - line.from) * w.length) / letters;    return { text: i === 0 ? w : ` ${w}`, from, to: t };  });};// The whole line shows and the current word takes the episode's color.const Caption: React.FC<{ line: Line; color: string }> = ({ line, color }) => {  const frame = useCurrentFrame();  const { fps } = useVideoConfig();  const now = line.from + frame / fps;  return (    <div style={{ ...textStyle, maxWidth: 900 }}>      {words(line).map((w) => (        <span          key={w.from}          style={{ whiteSpace: "pre-wrap", color: now >= w.from && now < w.to ? color : "white" }}        >          {w.text}        </span>      ))}    </div>  );};export const City: React.FC<Episode> = ({ clip, color, lines }) => {  const { fps } = useVideoConfig();  return (    <AbsoluteFill style={{ backgroundColor: "black" }}>      <Video src={staticFile(clip)} />      {lines.map((line) => (        <Sequence          key={line.from}          from={Math.round(line.from * fps)}          durationInFrames={Math.round((line.to - line.from + 0.4) * fps)}        >          <AbsoluteFill            style={{ justifyContent: "flex-end", alignItems: "center", paddingBottom: 520 }}          >            <Caption line={line} color={color} />          </AbsoluteFill>        </Sequence>      ))}    </AbsoluteFill>  );};

FontFace loads Pretendard, and delayRender() holds the render until continueRender() says the font is ready. words() spreads a line's time over its words by their length. Each line plays inside a <Sequence>, where useCurrentFrame() counts from the Sequence's start, so the time in the video is line.from + frame / fps. Each line stays 0.4 seconds past its end.

paddingBottom: 520 keeps the captions clear of the app's buttons, and wordBreak: keep-all wraps Korean between words, not inside them. src/Root.tsx registers the format as one composition, City. Shibuya's English episode is the default, and --props swaps in another at render time:

import { Composition } from "remotion";import shibuya from "../episodes/en/shibuya.json";import { City, FPS, calculateMetadata, episodeSchema } from "./City";export const RemotionRoot: React.FC = () => (  <Composition    id="City"    component={City}    schema={episodeSchema}    calculateMetadata={calculateMetadata}    defaultProps={shibuya}    fps={FPS}    width={1080}    height={1920}  />);

Remotion can list the compositions it finds:

npx remotion compositions
City    30      1080x1920      450 (15.00 sec)

450 frames is the default Shibuya episode. On a machine that hasn't run Remotion before, the first command also downloads a headless Chrome for rendering, once.

Step 6: Render every episode

With the format in one file and the episodes in others, rendering them all is a loop. basename turns episodes/en/albury.json into albury, so each episode gets its own file:

for f in episodes/en/*.json; do  npx remotion render City out/en/$(basename $f .json).mp4 --props=$fdone
+                    out/en/albury.mp4 12.8 MB
+                    out/en/hongkong.mp4 11.5 MB
+                    out/en/shanghai.mp4 15.1 MB
+                    out/en/shibuya.mp4 10.8 MB

Each render prints its progress; only its last line is shown here, where + marks a new file. The four take just under a minute on the Mac used here. A fifth city would be a fifth JSON file, and nothing else changes.

Step 7: Check them on a contact sheet

Claude Code can't play video, and four videos are already a lot to watch. A contact sheet puts them all on one image. fps=2/3 takes a frame every 1.5 seconds, scale=216:-2 shrinks each to 216 pixels wide and tile=10x1 lays ten in a row; magick -append then stacks the rows:

mkdir -p check/enfor f in out/en/*.mp4; do  ffmpeg -y -i $f -vf "fps=2/3,scale=216:-2,tile=10x1" -frames:v 1 check/en/$(basename $f .mp4).pngdonemagick check/en/*.png -append sheet-en.png

ffmpeg prints a warning for each file, because the output name has no frame number in it, and writes the image anyway. Albury's video is shorter, so its row gets nine frames and the last tile stays black.

Four rows of ten frames: Albury's night street, Hong Kong's rooftop, Shanghai's tower and Shibuya Crossing, with captions such as Causeway Bay, Hong / Kong and Then the tower lights / up that leave one word on the second line; Albury's last tile is black.
The first sheet. Rows from the top: Albury, Hong Kong, Shanghai and Shibuya, one frame every 1.5 seconds.

Nine of the 12 lines wrap, and six of them leave one word alone on the second line: Kong, billboards, river, up, Tokyo and again. In Hong Kong, the green word is hard to see on the pale roof. The uneven wraps are the format's problem; the faint green is one episode's.

Step 8: Fix the format

A fix in the component reaches every video. text-wrap: balance asks the browser to even out the lines when text wraps, and Remotion draws each frame in a browser, so one line in textStyle is enough:

// textStyle: even out the lines when a caption wrapstextWrap: "balance",

Then the same loop renders all four again. This time ○ marks a file it replaced:

for f in episodes/en/*.json; do  npx remotion render City out/en/$(basename $f .json).mp4 --props=$fdone
○                    out/en/albury.mp4 12.8 MB
○                    out/en/hongkong.mp4 11.5 MB
○                    out/en/shanghai.mp4 15.1 MB
○                    out/en/shibuya.mp4 10.8 MB
The caption area of three frames, before and after: Causeway Bay, Hong / Kong becomes Causeway Bay, / Hong Kong; Then the tower lights / up becomes Then the / tower lights up; The cars stop, the / crowd goes becomes The cars stop, / the crowd goes.
The caption area of each frame, before (left) and after (right) text-wrap: balance. From the top: Hong Kong, Shanghai and Shibuya.

The wrapped lines are now even. Hong Kong's green is still hard to see.

Step 9: Fix one episode

A dark box behind the words would make the green readable, but in the format it would box every city. So it goes in as an option that an episode turns on:

// episodeSchema: a dark box behind the words, for a bright backgroundbox: z.boolean().optional(),const boxStyle: React.CSSProperties = {  backgroundColor: "rgba(0,0,0,0.6)",  padding: "0 24px",  borderRadius: 20,  boxDecorationBreak: "clone",  WebkitBoxDecorationBreak: "clone",};// Caption: takes box, and puts the words in the box when it's on<div style={{ ...textStyle, maxWidth: 900, lineHeight: box ? 1.3 : 1.15 }}>  <span style={box ? boxStyle : undefined}>    {/* the words, as before */}  </span></div>// City: no box unless the episode turns it on({ clip, color, lines, box = false })<Caption line={line} color={color} box={box} />

box-decoration-break: clone gives each wrapped line its own padding and rounded corners, and with the box on, the line height grows to 1.3. box defaults to false, so the other episodes don't change. Hong Kong's episode turns it on:

{  "clip": "hongkong.mp4",  "color": "#5EE08A",  "box": true,  "lines": [    { "from": 0.6, "to": 2.8, "text": "Causeway Bay, Hong Kong" },    { "from": 3.4, "to": 6.6, "text": "Trams, buses and billboards" },    { "from": 9, "to": 12.4, "text": "Seen from a rooftop" }  ]}

Only Hong Kong needs rendering again, which takes about 14 seconds:

npx remotion render City out/en/hongkong.mp4 --props=episodes/en/hongkong.json
○                    out/en/hongkong.mp4 11.4 MB
Hong Kong at 4.5 seconds, twice: left, Trams, buses / and billboards in white with buses in green over the pale roof; right, the same caption in dark rounded boxes.
4.5 seconds into Hong Kong. Left, without the box; right, with it.

A change to the component could change every video, not only Hong Kong's. So Shibuya, which has no box, was rendered again to a second file and compared byte for byte with the one from step 8. cmp prints nothing and succeeds when the files are the same, so echo runs:

npx remotion render City ../tmp-shibuya.mp4 --props=episodes/en/shibuya.jsoncmp out/en/shibuya.mp4 ../tmp-shibuya.mp4 && echo identical
+                    ../tmp-shibuya.mp4 10.8 MB
identical

These are the four videos at the top of this guide.

Where it gets hard

The format fix came from one look at a sheet, and Hong Kong's from one word that was hard to read. Neither was an error; every render finished. With more episodes and versions, finding the frame and saying what's wrong is most of the work.

Cutfac is a Mac app we make for that part. It runs Claude Code or Codex for each video, lets you select a range or draw a box on the frame and say what to change, and keeps versions side by side to compare and pick from. You can do everything in this guide without it.

Free tools for this

Sources

Questions