One prompt you paste into Claude Code. Claude installs a few free tools and builds itself a /track command. Then you give it a video from your phone, and a virtual camera follows you and zooms with you. Ready for Reels, TikTok and Shorts.
Get the prompt ↓Copy the prompt. The button below copies all of it at once.
Paste it into Claude Code. Claude asks before it installs anything or writes a file. Say yes each time. It takes about five minutes.
Try it. Type /track and give it a video. For example: /track workout.mp4
Claude Code on your computer, Mac, Windows or Linux. You film on your phone, iPhone or Android, then copy the video to the computer. It does not run in the Claude app on your phone. No Claude Code yet? That takes about ten minutes: setting Claude up properly.
Set up a "track" skill so you can edit my videos with camera tracking: a virtual camera that follows me and zooms with me, like CapCut's camera tracking, but running on my own computer. Do it step by step and tell me in plain English what you are doing.
1. Check which computer I am on (Mac, Windows or Linux).
2. Install these free tools if they are missing:
- ffmpeg (reads and writes videos)
- uv (installs Python and the tracking packages without touching the rest of my computer)
Use these ways:
- Mac: install Homebrew first if it is missing, then: brew install ffmpeg uv
- Windows: winget install Gyan.FFmpeg astral-sh.uv (then open a new terminal so they are found)
- Linux: ffmpeg from the package manager, uv with: curl -LsSf https://astral.sh/uv/install.sh | sh
If something fails, explain why in one sentence and try the next best way.
3. Make the folder ~/.claude/skills/track/ and in it a private Python 3.12 with the tracking packages:
uv venv ~/.claude/skills/track/.venv --python 3.12
uv pip install --python ~/.claude/skills/track/.venv rtmlib onnxruntime opencv-python-headless numpy
The Python inside it is ~/.claude/skills/track/.venv/bin/python (on Windows: .venv\Scripts\python.exe).
The body tracking model (RTMPose, about 40 MB, free and open) downloads by itself the first time it runs.
4. Create the file ~/.claude/skills/track/track.py with exactly this content (if you ask me for permission to write it, I will say yes):
```python
#!/usr/bin/env python3
"""track: a virtual camera that follows the person in a video, like CapCut's camera tracking.
python track.py <video> [out.mp4] [--part body|shoulders] [--fill 0.62] [--y 0.56] [--show]
Finds 17 body points (RTMPose, runs on your own computer), smooths them, and cuts a 9:16 1080x1920 video
where the camera moves and zooms with you. --show draws the skeleton on top (for "how it works" clips).
"""
import argparse
import json
import subprocess
import sys
import cv2
import numpy as np
from rtmlib import Body
AW = 540 # analysis width (pose runs on a small copy, much faster)
POSE_EVERY = 2 # pose on every 2nd frame, the frame in between reuses it
KP_MIN = 0.35 # trust a body point from this score up
WFILL = 0.85 # the person never fills more than this much of the frame width
ZMAX = 2.8 # never zoom in more than this (sharp on 4K, use --zmax 2 for 1080p)
SIGMA = {"body": (7, 20), "shoulders": (5, 15)} # smoothing in frames at 30 fps: position, zoom
BONES = [(5, 7), (7, 9), (6, 8), (8, 10), (5, 6), (5, 11), (6, 12), (11, 12),
(11, 13), (13, 15), (12, 14), (14, 16), (0, 5), (0, 6)]
def probe(path):
"""Display width and height (phone videos are often stored sideways with a rotation flag), fps."""
out = subprocess.run(["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_streams", "-of", "json", path],
capture_output=True, text=True, check=True).stdout
s = json.loads(out)["streams"][0]
rot = int(float(s.get("tags", {}).get("rotate", 0)))
for d in s.get("side_data_list", []):
rot = int(float(d.get("rotation", rot)))
w, h = s["width"], s["height"]
if abs(rot) % 180 == 90:
w, h = h, w
num, den = s["r_frame_rate"].split("/")
return w, h, float(num) / float(den)
def frames(path, w, h):
"""Every frame as an upright BGR image of size w x h (ffmpeg applies the rotation flag)."""
p = subprocess.Popen(["ffmpeg", "-v", "error", "-i", path, "-vf", f"scale={w}:{h}", "-f", "rawvideo",
"-pix_fmt", "bgr24", "-"], stdout=subprocess.PIPE)
n = w * h * 3
while len(buf := p.stdout.read(n)) == n:
yield np.frombuffer(buf, np.uint8).reshape(h, w, 3)
p.wait()
def detect(path, aw, ah):
"""Keypoints [17, 3] (x, y in 0-1, score) per frame, None when nobody is found. Plus the shot cuts."""
body = Body(mode="lightweight", backend="onnxruntime", device="cpu")
poses, cuts, prev_hist = [], [0], None
for i, img in enumerate(frames(path, aw, ah)):
hist = cv2.calcHist([cv2.cvtColor(img, cv2.COLOR_BGR2HSV)], [0, 1], None, [32, 32], [0, 180, 0, 256])
cv2.normalize(hist, hist)
if prev_hist is not None and cv2.compareHist(prev_hist, hist, cv2.HISTCMP_CORREL) < 0.5:
cuts.append(i) # hard cut: smoothing restarts here
prev_hist = hist
if i % POSE_EVERY:
poses.append(poses[-1])
continue
kps, scores = body(img)
if len(kps):
j = int(np.argmax(scores.mean(axis=1))) # the most clearly visible person
poses.append(np.c_[kps[j][:, 0] / aw, kps[j][:, 1] / ah, scores[j]])
else:
poses.append(None)
if i % 150 == 0:
print(f" looked at {i} frames", file=sys.stderr)
return poses, cuts
def box(pose, part, aspect):
"""[centre x, centre y, height, width] of the part in 0-1 of the frame, or None."""
if pose is None:
return None
ok = pose[:, 2] >= KP_MIN
pt = lambda k: pose[k, :2] if ok[k] else None
head = [pt(k) for k in range(5) if ok[k]]
ls, rs = pt(5), pt(6)
if not head or ls is None or rs is None:
return None
neck = (ls[1] + rs[1]) / 2
head_top = min(p[1] for p in head)
hair = 0.6 * max(0.02, abs(neck - head_top)) # room above the eyes for the hair
if part == "shoulders":
sw = abs(ls[0] - rs[0]) / aspect # shoulder width in height units
top, bottom = head_top - hair, min(1.0, neck + 0.35 * max(sw, 0.05))
cx = (ls[0] + rs[0] + np.mean([p[0] for p in head])) / 3
return [cx, (top + bottom) / 2, bottom - top, abs(ls[0] - rs[0]) * 1.6]
vis = [pose[k, :2] for k in range(17) if ok[k]]
if len(vis) < 5:
return None
xs, ys = [p[0] for p in vis], [p[1] for p in vis]
top = min(head_top - hair, min(ys) - 0.04) # feet can be above the head (rolls, kicks)
bottom = min(1.0, max(ys) + 0.04)
torso = [p for p in (ls, rs, pt(11), pt(12)) if p is not None]
cx = (np.mean([p[0] for p in torso]) + (min(xs) + max(xs)) / 2) / 2 # calm torso + whole body
return [cx, (top + bottom) / 2, bottom - top, max(xs) - min(xs) + 0.04]
def smooth(rows, cuts, sig_c, sig_h):
"""Fill the gaps and smooth forwards and backwards (no lag), each shot on its own."""
n = len(rows)
a = np.array([r if r else [np.nan] * 4 for r in rows], float)
edges = sorted({*cuts, n})
for s, e in zip(edges, edges[1:]):
seg = a[s:e]
good = ~np.isnan(seg[:, 0])
if not good.any():
seg[:] = [0.5, 0.5, 0.8, 0.3] # nobody in this shot: wide, centred
continue
idx = np.arange(len(seg))
for c, sig in ((0, sig_c), (1, sig_c), (2, sig_h), (3, sig_h)):
x = np.interp(idx, idx[good], seg[good, c])
r = int(3 * sig)
k = np.exp(-0.5 * (np.arange(-r, r + 1) / sig) ** 2)
seg[:, c] = np.convolve(np.pad(x, r, mode="edge"), k / k.sum(), mode="valid")
return a
def main():
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("video")
ap.add_argument("out", nargs="?")
ap.add_argument("--part", choices=["body", "shoulders"], default="body",
help="body = whole person (training, dancing), shoulders = head and shoulders (talking)")
ap.add_argument("--fill", type=float, default=None,
help="how much of the frame height the person fills. 0.55 wide and calm, 0.66 floor work, 0.74 jumps")
ap.add_argument("--y", type=float, default=0.56, help="where the person's middle sits, 0 top to 1 bottom")
ap.add_argument("--zmax", type=float, default=ZMAX)
ap.add_argument("--show", action="store_true", help="draw the body points and skeleton")
a = ap.parse_args()
fill = a.fill or (0.62 if a.part == "body" else 0.8)
out = a.out or a.video.rsplit(".", 1)[0] + "_tracked.mp4"
w, h, fps = probe(a.video)
aw, ah = AW, round(AW * h / w / 2) * 2
print(f"Video {w}x{h} at {fps:.0f} fps. Step 1 of 2: finding the person...", file=sys.stderr)
poses, cuts = detect(a.video, aw, ah)
scale = fps / 30
sig_c, sig_h = (s * scale for s in SIGMA[a.part])
track = smooth([box(p, a.part, aw / ah) for p in poses], cuts, sig_c, sig_h)
# the largest 9:16 window that fits in the video, and the smallest we allow (max zoom)
full_h = min(h, w * 16 / 9)
print(f"Step 2 of 2: filming {len(track)} frames with the virtual camera...", file=sys.stderr)
enc = subprocess.Popen(["ffmpeg", "-v", "error", "-y", "-f", "rawvideo", "-pix_fmt", "bgr24", "-s", "1080x1920",
"-r", f"{fps}", "-i", "-", "-i", a.video, "-map", "0:v", "-map", "1:a?", "-c:v", "libx264",
"-crf", "18", "-preset", "medium", "-pix_fmt", "yuv420p", "-c:a", "aac", "-b:a", "192k",
"-t", f"{len(track) / fps:.3f}", "-movflags", "+faststart", out], stdin=subprocess.PIPE)
for i, img in enumerate(frames(a.video, w, h)):
cx, cy, ph, pw = track[min(i, len(track) - 1)]
need = max(ph * h / fill, pw * w / WFILL * 16 / 9) # tall enough for the person, and wide enough
ch = float(np.clip(need, full_h / a.zmax, full_h))
cw = ch * 9 / 16
x0 = float(np.clip(cx * w - cw / 2, 0, w - cw))
y0 = float(np.clip(cy * h - a.y * ch, 0, h - ch))
crop = img[int(y0):int(y0 + ch), int(x0):int(x0 + cw)]
frame = cv2.resize(crop, (1080, 1920), interpolation=cv2.INTER_AREA if ch >= 1920 else cv2.INTER_CUBIC)
if a.show and poses[min(i, len(poses) - 1)] is not None:
p = poses[min(i, len(poses) - 1)]
xy = [((p[k, 0] * w - x0) * 1080 / cw, (p[k, 1] * h - y0) * 1920 / ch) for k in range(17)]
for s, e in BONES:
if p[s, 2] >= KP_MIN and p[e, 2] >= KP_MIN:
cv2.line(frame, tuple(map(int, xy[s])), tuple(map(int, xy[e])), (255, 230, 80), 6, cv2.LINE_AA)
for k in range(17):
if p[k, 2] >= KP_MIN:
cv2.circle(frame, tuple(map(int, xy[k])), 10, (255, 255, 255), -1, cv2.LINE_AA)
try:
enc.stdin.write(frame.tobytes())
except BrokenPipeError: # the writer stopped early, keep what it has
break
try:
enc.stdin.close()
except BrokenPipeError:
pass
enc.wait()
print(f"Done: {out}", file=sys.stderr)
if __name__ == "__main__":
main()
```
5. Create the file ~/.claude/skills/track/SKILL.md with this content:
```
---
name: track
description: Camera tracking for my videos. A virtual camera follows me and zooms with me, output 9:16 1080x1920 for Reels, TikTok and Shorts. Use when I say "/track <video>", "add camera tracking", "make the camera follow me", or "track this clip".
---
# track
Run (use the Python inside ~/.claude/skills/track/.venv):
python ~/.claude/skills/track/track.py "<video>" ["<out.mp4>"] [options]
Pick the options from what is in the video. Look at 3 or 4 frames first if you are not sure:
ffmpeg -ss <time> -i "<video>" -frames:v 1 -vf scale=480:-1 peek.jpg
- Training, dancing, the whole body moving: default (--part body). Calm or far away: --fill 0.55.
Floor work, lunges, Turkish get-ups: --fill 0.66. Jumps and fast moves: --fill 0.74.
- Talking to the camera: --part shoulders
- Wants to show how it works (the skeleton on top): --show
- Video smaller than 4K: add --zmax 2 so the zoom stays sharp.
- Several clips: run them one after the other. Videos with hard cuts are fine, the camera restarts at every cut.
It takes about 5 seconds of computer time per second of 4K video.
Afterwards, check the result before telling me it is done: save 6 frames spread over the video into one picture
ffmpeg -i "<out.mp4>" -vf "fps=<6 / length in seconds>,scale=270:480,tile=6x1" -frames:v 1 check.jpg
and look at it. If heads or feet are cut off, run again with a smaller --fill (0.05 less). If the person looks
small, use a bigger --fill. Tell me where the file is.
```
6. Ask me for a short video of mine (10 to 30 seconds, filmed on my phone, one person moving). Run /track on it, show me the check picture from step 5, and tell me where the new video is.
7. Tell me in one sentence how to use it from now on: type /track and give it a video file.
It finds you. A small, open AI model finds 17 points on your body, 15 times a second. Head, shoulders, hips, knees, feet.
It smooths. The camera looks ahead and back, so it never lags behind you and never shakes. At every cut in the video it starts fresh.
It films again. From your video it cuts a 9:16 frame that moves and zooms with you. Head and feet stay in, even on the floor. Your sound stays.
--show you see the skeleton on top of the video. Good for showing how it worksEverything runs on your own computer, nothing is uploaded. The tools (ffmpeg, RTMPose, OpenCV) are open source and free. A 30-second 4K video takes about two to three minutes. If someone walks right up to the phone, no camera can help: just cut those seconds.
I post skills on Instagram regularly, and the full guide always ends up here on the site, free and without a signup.