Checked November 16, 2026 (15:25 CST, UTC+8). I build bamabound.app, which turns one photo of one person into a vertical clip of them holding a red I'M BAMA BOUND banner. The clip measured here is the "Imported field preview" on the site, which the site labels "Imported reference, not this studio's output." I only measured it. It isn't re-published here, and there are no frames of it in this post.
A reference-video generator works like this: you give it one photo, and the model animates that person by following a reference clip's motion and timing. The meme page says the preset "replaces the banner holder with the person in your photo and keeps the red I'M BAMA BOUND banner". The photo guide says "the banner wording, the field, and the timing stay with the preset."
So there's a practical question behind "why does my Bama Bound clip look shaky?" and "should I stabilize it before posting?". How much of the movement in the reference is the camera, and how much is the person and the banner? When I measured frame-to-frame change on this clip two days ago, the median change was high all the way through. Frame differences can't tell a moving camera from a moving subject, though. This post separates the two with one ~100-line Python file, checks it on clips with known motion, and then tries a stabilizer on the reference to see what happens.
The method: phase correlation, four times per frame
If the whole picture shifts by (dx, dy) between two frames, the shift shows up as a sharp peak in the inverse FFT of their normalised cross-power spectrum. That's phase correlation, and it's a few lines of NumPy. The peak height (0 to 1) tells you how well the two frames still match.
Pan is phase correlation on the whole frame. For zoom, the script runs the same thing on the left and right halves, and on the top and bottom halves. If the halves move apart, the camera zoomed in. If they move together, it zoomed out. Two details turned out to matter, and the tests below show both:
- Analyse at 360x640, not 180x320. The parabolic sub-pixel fit is biased toward whole pixels. At 180 px wide, a slow vertical pan of 30 px/s read as 89.8 px over 4 s instead of 118.75.
- Measure zoom over a 6-frame gap. A 0.1%-per-frame zoom moves the half-frames apart by about a tenth of a pixel per frame. That's below what the sub-pixel fit can resolve, so comparing frame i with frame i−6 works better.
All shifts are reported in pixels of a 720-px-wide frame, so a 480p and a 1080p copy give comparable numbers.
#!/usr/bin/env python3
"""camera_motion.py - estimate pan and zoom per frame of a short vertical clip.
Phase correlation (NumPy FFT) between consecutive greyscale frames gives the
global shift. The same is done on a left/right and top/bottom pair of blocks;
the blocks moving apart means zoom-in, moving together means zoom-out.
usage: python3 camera_motion.py clip.mp4 [--w 360 --h 640] [--zoom-gap 6] [--csv out.csv]
Shifts are reported in pixels of a 720-px-wide frame so clips of different
resolutions are comparable (keep --w/--h at the clip's own aspect ratio). Needs ffmpeg/ffprobe on PATH and NumPy.
"""
import argparse, json, subprocess, sys
import numpy as np
def probe_fps(path):
out = subprocess.run(["ffprobe", "-v", "error", "-select_streams", "v:0",
"-show_entries", "stream=r_frame_rate", "-of", "json", path],
capture_output=True, text=True, check=True).stdout
n, d = json.loads(out)["streams"][0]["r_frame_rate"].split("/")
return float(n) / float(d)
def frames(path, w, h):
cmd = ["ffmpeg", "-v", "error", "-i", path, "-vf", f"scale={w}:{h}:flags=area,format=gray",
"-f", "rawvideo", "-"]
raw = subprocess.run(cmd, capture_output=True, check=True).stdout
return np.frombuffer(raw, np.uint8).reshape(-1, h, w).astype(np.float32)
def phase_shift(a, b):
"""Return (dx, dy, peak) such that b ~= a shifted by (dx, dy)."""
win = np.outer(np.hanning(a.shape[0]), np.hanning(a.shape[1])).astype(np.float32)
A = np.fft.fft2((a - a.mean()) * win)
B = np.fft.fft2((b - b.mean()) * win)
R = np.conj(A) * B
R /= np.abs(R) + 1e-9
r = np.fft.ifft2(R).real
py, px = np.unravel_index(np.argmax(r), r.shape)
def sub(c, m, n): # parabolic sub-pixel refinement along one axis
l, cc, rr = m[(c - 1) % n], m[c], m[(c + 1) % n]
den = l - 2 * cc + rr
return c + (0.5 * (l - rr) / den if den != 0 else 0.0)
fy = sub(py, r[:, px], r.shape[0]); fx = sub(px, r[py, :], r.shape[1])
if fy > r.shape[0] / 2: fy -= r.shape[0]
if fx > r.shape[1] / 2: fx -= r.shape[1]
return fx, fy, float(r[py, px])
def main():
ap = argparse.ArgumentParser()
ap.add_argument("clip"); ap.add_argument("--w", type=int, default=360)
ap.add_argument("--h", type=int, default=640); ap.add_argument("--csv")
ap.add_argument("--zoom-gap", type=int, default=6,
help="measure zoom between frames this far apart (tiny per-frame zooms are below sub-pixel accuracy)")
a = ap.parse_args()
fps = probe_fps(a.clip); F = frames(a.clip, a.w, a.h); k = 720.0 / a.w
h2, w2 = a.h // 2, a.w // 2
rows = []
for i in range(1, len(F)):
p, q = F[i - 1], F[i]
dx, dy, peak = phase_shift(p, q)
g = min(a.zoom_gap, i); z0 = F[i - g]
lx, _, _ = phase_shift(z0[:, :w2], q[:, :w2]); rx, _, _ = phase_shift(z0[:, w2:], q[:, w2:])
_, ty, _ = phase_shift(z0[:h2], q[:h2]); _, by, _ = phase_shift(z0[h2:], q[h2:])
# block centres are w/2 (or h/2) apart; relative spread change = scale - 1 over g frames
scale_g = 1 + 0.5 * ((rx - lx) / w2 + (by - ty) / h2)
zoom = scale_g ** (1.0 / g) - 1
rows.append((i / fps, dx * k, dy * k, zoom * 100, peak))
R = np.array(rows)
if a.csv:
np.savetxt(a.csv, R, delimiter=",", fmt="%.4f",
header="t_s,dx_px720,dy_px720,zoom_pct_per_frame,peak", comments="")
print(f"{a.clip}: {len(F)} frames at {fps:g} fps, analysed at {a.w}x{a.h}, shifts in 720-px units")
print(" second | pan x px | pan y px | zoom % | min peak")
cx = cy = cz = 0.0
for s in range(int(np.ceil(R[-1, 0]))):
m = (R[:, 0] > s) & (R[:, 0] <= s + 1)
if not m.any(): continue
sx, sy = R[m, 1].sum(), R[m, 2].sum(); sz = (np.prod(1 + R[m, 3] / 100) - 1) * 100
cx += sx; cy += sy; cz = ((1 + cz / 100) * (1 + sz / 100) - 1) * 100
print(f" {s:>2}-{s+1:<3} | {sx:+8.1f} | {sy:+8.1f} | {sz:+6.2f} | {R[m,4].min():.3f}")
tz = (np.prod(1 + R[:, 3] / 100) - 1) * 100
print(f"total pan x {R[:,1].sum():+.1f} px, pan y {R[:,2].sum():+.1f} px, zoom {tz:+.2f}%")
print(f"median |shift| per frame {np.median(np.hypot(R[:,1], R[:,2])):.2f} px; "
f"max {np.hypot(R[:,1], R[:,2]).max():.2f} px at {R[np.argmax(np.hypot(R[:,1], R[:,2])),0]:.2f} s")
low = R[R[:, 4] < 0.05]
print(f"frames with weak match (peak < 0.05): {len(low)}" + (f", first at {low[0,0]:.2f} s" if len(low) else ""))
if __name__ == "__main__":
sys.exit(main())
Does it measure known motion correctly?
make_motion_test_clips.sh pans and zooms a seeded random texture with ffmpeg, so the true motion is known exactly. There are no people and no banner in it.
#!/usr/bin/env bash
# make_motion_test_clips.sh - synthetic 720x1280 clips with KNOWN camera motion.
# A seeded random texture (no people, no banner) is panned or zoomed by ffmpeg,
# so camera_motion.py can be checked against the true numbers.
set -euo pipefail
SEED=${SEED:-16}
python3 - "$SEED" <<'PY'
import sys, numpy as np
from PIL import Image, ImageFilter
rng = np.random.default_rng(int(sys.argv[1]))
img = Image.fromarray((rng.random((1800, 1200)) * 255).astype(np.uint8)).filter(ImageFilter.GaussianBlur(3))
a = np.asarray(img, np.float32); a = (a - a.min()) / (a.max() - a.min()) * 255
Image.fromarray(a.astype(np.uint8)).convert("RGB").save("texture.png")
PY
# 1) pan: 96 px/s to the right in the source = content moves LEFT on screen (dx = -4 px/frame at 24 fps), 4 s
ffmpeg -v error -y -loop 1 -framerate 24 -i texture.png -t 4 \
-vf "crop=720:1280:x='60+96*t':y=200,format=yuv420p" -c:v libx264 -crf 18 -preset veryfast pan_left.mp4
# 2) zoom-in: zoompan scales 1.000 -> ~1.096 over 96 frames (+0.1% per frame), centred, 4 s
ffmpeg -v error -y -loop 1 -framerate 24 -i texture.png -t 4 \
-vf "crop=1200:1800,scale=720:1080,pad=720:1280:0:100,zoompan=z='1+0.001*on':x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)':d=1:s=720x1280:fps=24,format=yuv420p" \
-frames:v 96 -c:v libx264 -crf 18 -preset veryfast zoom_in.mp4
# 3) static: same texture, no motion, 2 s
ffmpeg -v error -y -loop 1 -framerate 24 -i texture.png -t 2 \
-vf "crop=720:1280:60:200,format=yuv420p" -c:v libx264 -crf 18 -preset veryfast static.mp4
echo "made pan_left.mp4 zoom_in.mp4 static.mp4 (SEED=$SEED)"
A static clip should read zero, and it does:
$ python3 camera_motion.py static.mp4
static.mp4: 48 frames at 24 fps, analysed at 360x640, shifts in 720-px units
second | pan x px | pan y px | zoom % | min peak
0-1 | +0.0 | +0.0 | -0.00 | 0.999
1-2 | +0.0 | +0.0 | -0.00 | 1.000
total pan x +0.0 px, pan y +0.0 px, zoom -0.00%
median |shift| per frame 0.00 px; max 0.00 px at 0.04 s
frames with weak match (peak < 0.05): 0
A 96 px/s pan should read −96 px per second (the content moves left when the crop window moves right). The last second has 23 frame-steps instead of 24, which gives −92:
$ python3 camera_motion.py pan_left.mp4
pan_left.mp4: 96 frames at 24 fps, analysed at 360x640, shifts in 720-px units
second | pan x px | pan y px | zoom % | min peak
0-1 | -96.0 | +0.0 | +0.00 | 0.890
1-2 | -96.0 | +0.0 | +0.00 | 0.995
2-3 | -96.0 | +0.0 | -0.00 | 0.927
3-4 | -92.0 | -0.0 | +0.00 | 0.913
total pan x -380.0 px, pan y +0.0 px, zoom +0.00%
median |shift| per frame 4.00 px; max 4.04 px at 0.25 s
frames with weak match (peak < 0.05): 0
A diagonal pan at 50 px/s and 30 px/s should read −197.9 and −118.75 px in total (95 steps at 24 fps):
$ python3 camera_motion.py pan_slow.mp4
pan_slow.mp4: 96 frames at 24 fps, analysed at 360x640, shifts in 720-px units
second | pan x px | pan y px | zoom % | min peak
0-1 | -50.0 | -29.8 | -0.00 | 0.328
1-2 | -50.0 | -30.1 | -0.02 | 0.326
2-3 | -50.2 | -30.1 | +0.01 | 0.317
3-4 | -48.0 | -29.1 | -0.01 | 0.321
total pan x -198.1 px, pan y -119.2 px, zoom -0.02%
median |shift| per frame 2.28 px; max 3.43 px at 0.75 s
frames with weak match (peak < 0.05): 0
Here's the same clip analysed at 180x320. The vertical pan comes out about 24% short:
$ python3 camera_motion.py --w 180 --h 320 pan_slow.mp4 # lower analysis size
total pan x -200.2 px, pan y -89.8 px, zoom -0.03%
median |shift| per frame 2.12 px; max 3.49 px at 0.75 s
frames with weak match (peak < 0.05): 0
And a zoom-in from 1.000 to about 1.095 (ffmpeg zoompan, +0.1% per frame). I checked the true end-to-end scale separately by brute-force matching the first and last frames, and it came out at 1.095:
$ python3 camera_motion.py zoom_in.mp4
zoom_in.mp4: 96 frames at 24 fps, analysed at 360x640, shifts in 720-px units
second | pan x px | pan y px | zoom % | min peak
0-1 | -3.6 | -3.8 | +2.64 | 0.496
1-2 | -3.9 | -4.4 | +2.44 | 0.486
2-3 | -4.0 | -5.7 | +2.40 | 0.556
3-4 | -2.3 | -3.9 | +2.20 | 0.474
total pan x -13.9 px, pan y -17.8 px, zoom +10.03%
median |shift| per frame 0.40 px; max 2.54 px at 3.54 s
frames with weak match (peak < 0.05): 0
That's +10.03% against a true +9.5%, so it's about half a percentage point high over 4 seconds. With consecutive frames (--zoom-gap 1), it under-reads at +8.36%:
$ python3 camera_motion.py --zoom-gap 1 zoom_in.mp4 # consecutive-frame zoom
total pan x -13.9 px, pan y -17.8 px, zoom +8.36%
median |shift| per frame 0.40 px; max 2.54 px at 3.54 s
frames with weak match (peak < 0.05): 0
The small leftover pan in the zoom test (−13.9 / −17.8 px) is real. zoompan rounds its x/y window to whole pixels, so the centre drifts a little. On these tests the script is good to about a pixel for pan and about ±1 percentage point for zoom over a few seconds.
The reference clip: the camera barely moves
$ python3 camera_motion.py ref.mp4 --csv ref_motion.csv
ref.mp4: 193 frames at 24 fps, analysed at 360x640, shifts in 720-px units
second | pan x px | pan y px | zoom % | min peak
0-1 | -5.1 | +18.2 | +0.22 | 0.203
1-2 | +4.8 | +2.4 | +1.32 | 0.264
2-3 | +4.9 | +11.4 | -0.33 | 0.195
3-4 | -3.1 | +12.5 | -0.95 | 0.178
4-5 | -3.0 | -5.1 | -0.94 | 0.193
5-6 | -1.9 | -15.6 | -1.29 | 0.226
6-7 | -2.7 | -15.1 | +0.81 | 0.213
7-8 | +2.6 | -7.2 | -2.25 | 0.241
total pan x -3.5 px, pan y +1.6 px, zoom -3.40%
median |shift| per frame 0.37 px; max 4.63 px at 0.17 s
frames with weak match (peak < 0.05): 0
In plain words:
- Net pan is basically zero. Over 8 seconds it's −3.5 px sideways and +1.6 px vertically, on a 720-px-wide frame. The camera isn't panning anywhere.
- There's a slow vertical bob. The picture drifts down about 44 px during the first 4 s (+18.2, +2.4, +11.4, +12.5), then comes back up about 43 px (−5.1, −15.6, −15.1, −7.2). That's a gentle tilt or crane move, roughly 11 px per second, nothing like handheld shake. The median per-frame shift is 0.37 px.
- There's a slow pull-out of about 3.4% in total, mostly after 3 s.
- The match peak stays between 0.18 and 0.26 the whole time. The texture-only pan test sat at 0.32-1.00. A lower but steady peak means large parts of each frame change in ways a single shift can't explain. That's the person and the banner moving, not the camera.
That fits what the frame-difference numbers suggested on Saturday. The clip is busy, but the busyness is the subject. The camera is almost locked off.
So should you stabilize your clip?
No. This was the result I didn't expect. Running a stabilizer on the reference made the camera worse:
ffmpeg -i ref.mp4 -vf vidstabdetect=result=t.trf -f null -
ffmpeg -i ref.mp4 -vf vidstabtransform=input=t.trf:smoothing=30 -c:v libx264 -crf 18 -preset veryfast -an stab.mp4
$ python3 camera_motion.py stab.mp4 # after vidstabdetect + vidstabtransform smoothing=30
stab.mp4: 193 frames at 24 fps, analysed at 360x640, shifts in 720-px units
second | pan x px | pan y px | zoom % | min peak
0-1 | -1.6 | +8.5 | +0.49 | 0.159
1-2 | +13.2 | +6.3 | +0.11 | 0.151
2-3 | -14.2 | +10.9 | +0.62 | 0.085
3-4 | +23.2 | +17.6 | -0.16 | 0.077
4-5 | -14.9 | -16.3 | -2.67 | 0.088
5-6 | -0.5 | -27.9 | -0.93 | 0.095
6-7 | -3.6 | -18.5 | +0.90 | 0.196
7-8 | +4.8 | -9.4 | -2.49 | 0.194
total pan x +6.6 px, pan y -28.8 px, zoom -4.13%
median |shift| per frame 1.30 px; max 18.78 px at 4.46 s
frames with weak match (peak < 0.05): 0
The median per-frame shift went from 0.37 px to 1.30 px, and the largest single-frame jump from 4.63 px to 18.78 px. The peak dropped to 0.08-0.10 in the middle seconds. A stabilizer tracks features, and in this clip the strongest features are the banner and the person, which are the things that move. So it "corrects" the subject's motion by moving the whole frame, and that adds camera motion that wasn't there before.
One more thing to know if you try it: vidstabdetect didn't give the same result twice on this box, even with -threads 1. The transform files had different hashes on every run:
$ # determinism check: vidstab twice, then -threads 1 twice
93e2ffef156c0354766c59cc9b10b5ea t1.trf
67cd6096611cc7dd8dc15f2b43ed31d2 t2.trf
1934d375bf6befc07ae62f0dac1ad903 u1.trf
7890b98796830fdc259908abcd88f69c u2.trf
The exact stabilized numbers above will differ on a re-run. The direction (worse, not better) is what I'd rely on.
Using it on your own clip
- Run
python3 camera_motion.py your_clip.mp4. Keep--w/--hat your clip's aspect ratio (360x640 for 9:16). - Look at total pan and the median per-frame shift. The reference is under 4 px net and 0.37 px median. A generated clip follows the reference's motion, so numbers in that range mean the camera is doing what the preset does.
- If your median is several pixels and the per-second pan swings back and forth, the jitter came from somewhere else: a phone screen recording, a re-edit with a "zoom" effect, or a stabilizer. Go back to the original download.
- Don't stabilize a clip whose camera is already this still. The FAQ says the preset follows the reference timing, about eight seconds in 9:16. Leave the motion alone too.
Limits
- This is a global-motion model: one shift plus a zoom per frame. Rotation and perspective aren't measured. A big moving subject can pull the estimate, which is why the peak value is printed.
- The zoom estimate was checked against one synthetic zoom (+9.5% true, +10.03% measured). Treat values under about 1% per second as noise.
- One real clip, one box: Python 3.13.5, NumPy 2.5.4, ffmpeg 7.1.5. Every number above comes from one logged run; the synthetic tests are reproducible with the two scripts in this post.
If you want your own clip to measure: on November 16, 2026 the pricing page listed 480p $7.98, 720p $9.98, 1080p $16.98 and 4k $24.98 per clip, tax added at checkout, with no subscription. You upload one photo in the studio and don't write a prompt.
Top comments (0)