/og-video-preview:og-video-previewfrom og-video-preview
Turns approved Open Graph images into looping og:video previews that play in iMessage, Discord, and Telegram while showing a matching still elsewhere. Covers layer extraction, motion presets, Playwright capture, ffmpeg encoding, and server requirements.
Ships in og-video-preview. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
scripts/check_collide.py (opens in a new tab)scripts/check_frame0.py (opens in a new tab)scripts/check_live.sh (opens in a new tab)scripts/check_loop.py (opens in a new tab)scripts/encode.sh (opens in a new tab)scripts/make_plate.py (opens in a new tab)scripts/render_frames.py (opens in a new tab)scripts/suggest_layers.py (opens in a new tab)template/from-image.html (opens in a new tab)template/og.html (opens in a new tab)worker/range-worker.js (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub hubeiqiao/og-video-preview --plugin og-video-previewAn OG video is a short, silent, looping MP4 that link previews can play in place of the share image. The workflow is always the same:
og:image. Nothing moves until the picture is right.Two routes for step 2:
| Route | Use when | Start from |
|---|---|---|
| A. From the approved image (default) | You have the final PNG/JPG, made anywhere (Figma, Canva, a generator, a screenshot) | template/from-image.html + scripts/suggest_layers.py |
| B. From an HTML card | You are designing the card in code and want to change its text later without a new image | template/og.html |
Requirements: Python 3 with playwright, Pillow, opencv-python and numpy; Chrome installed (Playwright uses channel="chrome"); ffmpeg and ffprobe. Optional: Tesseract and pytesseract, which find type on photos and 3D scenes and screen out texture that only looks like text.
Before anything is cut, look at the card and say what it shows, the way a person would: what are its parts, which of them belong together, and what would each one do if the card came alive? The automatic reading (suggest_layers.py) finds elements from pixels, so it cannot know that six panels are windows of one app, that a pill with words in it is a button, that a column of fading lines is a list scrolling through a highlight, or that the avatars around a mark are a community orbiting it. Write what you see as a plan, scene.json, and pass it with --scene; where the plan says nothing, the automatic reading stands.
{"note": "A call-to-action button on a dotted field: the button is one unit, and a pointer clicks it.",
"units": [
{"box": [228, 238, 744, 228], "role": "button"},
{"box": [524, 62, 152, 70], "role": "logo"}
]}
Each unit is a box in card pixels and a role. Everything the reading found inside the box joins it, so it moves as one piece; a unit listed earlier keeps its own pixels (list a chair before the scribble it sits on).
| Role | Use it for | How it moves |
|---|---|---|
window, panel | an app window, a card in a collage, a screenshot | whole, its full rectangle; leaves and comes back in one piece. A box drawn by eye usually stops inside the window's border: it grows out to where the card is plain again, so the border and drop shadow leave with it |
button | a call to action: a pill or a box with words in it | a pointer glides in, hovers, clicks; the button presses and a ripple spreads inside it |
scribble | a brush stroke, a hand-drawn line or arrow | draws itself at a pen's pace; dir gives the way ([1, 0] left to right, [0, -1] upward); ink (a hex colour) takes only that colour from the box, tol how far from it (120 by default; more for an anti-aliased end over another colour) |
medallion | a coin, a relief, a seal | leans in slowly while light glides across it |
float | a sticker, a balloon, a print in a scattered collage | never leaves: drifts on its own path all through the loop (a little sideways, up and down, a slight turn and 3D tilt); "cut": "rect" takes the whole box (a photo tile) instead of its foreground, for tiles that stand apart: tiles that overlap leave seams of each other in the plate |
typing | the text in a prompt box, a search field, a chat input | deleted a letter at a time, a caret blinking, then typed again; whole at both ends of the loop. A long line changes only its last 24 letters, so it is whole again before the loop ends. Box the text and its caret; caret sets the caret's colour. The card's own caret is hidden while the drawn one shows, so two never stand side by side. The input's own fill goes behind it |
blob | a soft decorative blob of colour | its edge flows like liquid and settles back; the only unit that ever warps |
logo, headline, text, illustration, photo, shape, icon | anything the reading split or merged wrongly | as that kind. Give a mark the move that fits what it shows with turn: spin for a gear or a round badge, wobble for a bell, nudge for an arrow (back for one pointing left), beat for a heart or a bolt, pop for anything else |
orbit (region) | avatars or icons around a central mark | every small round thing turns about center by the same angle and back, whole and upright, so the ring keeps its spacing and none runs into another; inner keeps the mark still, deg is the turn (keep it under about 10 on a full card: the outer ones travel furthest) |
marquee (region) | a row of logos running off the card | the row slides sideways and back by shift px; give rows opposite dir. Give pitch (the distance from one logo to the next): the row is then its whole logos repeated, what slides in at an edge is a whole logo, and the half logo the card's edge cut fades as the row starts to move |
list (region) | a word rotator: a column of lines with one highlighted | scrolls through the highlight by pitch (the row height), center is the highlighted row's centre, bar its highlight; each line darkens in the highlight and fades away from it, as on the card |
slide (region) | a piece on a board: a filled tile in a lattice of empty ones, a token on a grid | slides one cell (move, in px) and back; the cell it leaves shows what the card has in the empty cell it moves to (the lattice's own lines and grain), so nothing is refilled. ink is its colour; its anti-aliased rim goes with it |
shine (region) | a lamp, a glass orb, a star | a soft light swells there twice |
A plan can also set how the card as a whole moves, beside units:
| Key | Use it for | What it does |
|---|---|---|
surface | a background that is itself the picture: silk ribbons, a gradient field, a flame | {"form": "silk", "amp": 2.6, "angle": 11} moves the whole background as one surface. silk billows along angle (degrees) with a soft band of light gliding along it; ripple and wind are the other forms; amp scales how far it moves (1 by default). The type keeps a calm zone, so it never bends. On a graded background with no plan, the reading picks silk or ripple on its own |
accent | a light the card's own colours suggest | a hex colour ("#ffd9a0") for the light that sweeps through type, which white type otherwise does not take |
fx | choosing an effect instead of leaving it to the card's seed | headline: sheen (light through the letters), hop (letters hop in turn) or none (no sweep: on type over a coloured field where the sweep would light a box, not letters). mark: spin, flip, wobble or pop. pill: sheen or orbit |
only | a card where the reading found pieces that belong to the picture (the dots of a pattern, the strokes of an illustration) | true: only the plan's units move; everything else stays in the plate |
A region moves a part of the card itself, sampled from the card, so nothing the refill made turns into view. The eval keeps its plans in eval/scenes/ (Webflow's windows, Cloudflare's button, OpenAI's scribbles and floating stickers, Deno's list, Ghost's orbit, Y Combinator's carousel, a16z's medallion, Fly's Sign up button, Lovable's prompt being typed, Chatbase's tiles sliding on their lattice) and shows each of those cards both ways.
Read for what a person would expect to move: a call to action is clicked, a prompt is typed, a drawn line draws, a carousel slides, a list scrolls, things scattered around a mark drift or orbit, an app window is one piece. Leave alone what should hold still: a wordmark is one shape (never letters), a cloud or any wide mark never spins, a portrait never comes apart.
SKILL=~/.claude/skills/og-video-preview # the folder this SKILL.md is in
mkdir -p og && cp $SKILL/template/from-image.html og/
python3 $SKILL/scripts/suggest_layers.py approved.png og --scene scene.json # your reading (optional): card.jpg, layers.js, plate.png, cuts
python3 $SKILL/scripts/render_frames.py og/from-image.html og/frames --frames 0,20,40,60,90,150 # preview; prints the motion plan
python3 $SKILL/scripts/check_frame0.py og/card.jpg og/frames/f0000.png
python3 $SKILL/scripts/render_frames.py og/from-image.html og/frames # all frames
python3 $SKILL/scripts/check_loop.py og/frames
python3 $SKILL/scripts/check_collide.py og # nothing touches while it moves (--fix calms the mover)
bash $SKILL/scripts/encode.sh og/frames public/og/home-v1 # home-v1.mp4 + home-v1.jpg
Requires opencv-python and numpy besides Playwright and Pillow. Any size or ratio works: the card is cover-cropped to 1200×630 first.
suggest_layers.py models the background (a flat colour, or a smooth estimate under a gradient or photo), marks everything that stands out, groups it into elements, and decides what each one is from how it looks. Three cases are handled before that:
| Kind | How it is recognised |
|---|---|
headline | text lines whose cap height is near the largest on the card |
text | other text lines (one colour, many glyphs of regular height) |
label | small text: kickers, URLs, captions |
logo | a mark at the start of, or just left of, a text line: taller than its letters, another colour, or solid |
pill | a solid bar, wider than tall, with content in it: tags, buttons |
icon | a small graphic with inner detail: emoji, mascots, app icons |
avatar | a round element with photo detail |
photo | a solid rectangle with many colours |
panel | a large solid surface: screenshots, UI cards, sticky notes |
illustration | a larger multicolour graphic |
shape | a one-colour form: dots, squares, blobs, triangles |
stroke | thin and long: lines, arrows, underlines, squiggles |
Text is split into lines and lines into words (never into letters: a letter rising in its own narrow mask is cut by it). Look at layers-preview.png (each box is labelled with its id; the underline marks its parts). If an element is read wrongly, change its kind in layers.js; that needs no new cut. A box you add by hand is cut as a rectangle (or a disc with "cut": "disc"); run make_plate.py og after adding or removing boxes. To change which pixels an element owns, re-run suggest_layers.py instead.
make_plate.py writes:
plate.png: the card with every element removed and the background refilled (smooth fill for shapes, texture-preserving inpaint behind type on photos and gradients).layers.png: the card with alpha 1 over each element and a soft edge just outside it. Where the alpha is partial, plate and card are identical, so the layers over the plate reproduce the card exactly. Type keeps only its glyphs: no box of background travels with a word.cuts/<id>.png: the same, one image per layer with only that layer's pixels, so boxes may overlap (tight leading, a pill inside a line) without a line carrying pieces of its neighbour.glyphs.png: each element's own pixels, a mask for light sweeps.light.png: where an element is lighter than the refilled background behind it, the mask for the light that runs through a picture that stays in place.A soft shadow or glow travels with its element: faint pixels around it that differ from the background model are part of its cut.
A clean background lets everything move. A refill is never perfect behind a large visual on a picture, which is why such visuals settle in place. When an image-edit tool is available (any model that can edit an image from a reference), ask it for the approved image with every element removed: the background alone, same colour, light and texture, no ghost outlines (check it at 3x where the elements were). Pass it to the analyzer:
python3 $SKILL/scripts/suggest_layers.py og.jpg og --plate og-clean.png
make_plate.py then fills every hole from it, nothing has to settle, and the style becomes flow. For a visual-led card (an illustration, a scene of separate objects), this is what makes it lively; design such a card with its objects apart from each other, so each can move on its own.
Each kind has an entrance, an exit, an idle movement and an accent, built on the house tokens of physical-motion-design: cubic-bezier(0.22, 1, 0.36, 1) (smooth) for entrances, cubic-bezier(0.35, 1.55, 0.65, 1) (spring) only for pops, damped springs for anything with weight, and exits that are the smooth curve reversed (softer and shorter than entrances).
| Kind | Enters | Leaves | Lives | Accent |
|---|---|---|---|---|
headline | each line rises whole out of its own mask, on a spring; lines follow one another | sinks back into the mask | stays still | the card's choice: a light sweep through the glyphs, or the words hopping in turn (on a flat card, never on a wordmark); camera punch when the last line lands |
text | fade + 14 px rise + 3 px blur clearing, 0.42 s smooth | fade, drop, blur | sweep if it has an accent colour | |
label | wipes on left to right with a short slide | fade | ||
logo | scales up from 35 % with a spin, on a spring | shrinks and turns away | gentle bob and tilt | the card's choice of one turn: flat, over in 3D like a coin, a swing that settles, or a pop. Only a round or square mark turns; a wide one (a cloud, a wordmark) pops |
| wordmark | unfurls out of its logo, left to right | sweep | ||
pill | pops on the spring curve (overshoot) | shrinks | a small pulse (living) | a sweep, or a light circling it |
icon | springs up from 30 % with a small turn | shrinks | bob and tilt | the same turn as the card's logo; in a crowd of more than three, small icons only pop in turn |
avatar | springs up from 50 % with a turn | shrinks and turns | float | |
photo | opens from the middle (clip) while settling from 110 % | fade, slight shrink | slow push-in and drift | |
panel | lifts 42 px with a scale from 94 % and a clearing blur | fade, drop | float | glancing reflection |
illustration | rises with a squash on landing | fade, drop | sway and bob | |
shape (small) | pops from 0, rippling outward from the headline | shrinks to 0 | twinkle | |
shape (large) | grows from 80 % out of a blur | fade | bob; it stays rigid (a liquid edge only for a unit the reading calls blob) | |
stroke | draws at a pen's even pace along its long axis; an arrow (its two barbs found on the skeleton) draws from its tail to its head | undraws | redraws (living) |
Visuals that cannot leave cleanly hold still instead. A photo, panel, illustration or avatar that sits on something other than the plain background (a photo inside a UI, a poster in a stack), covers a fifth of the card, or whose refill would show, never exposes the plate: it stays exactly where it is (no lean, no blur: a part of a picture moving on its own reads as a glitch) and does not turn. Light then runs through its own lit parts (light.png: where it is brighter than the background behind it), so a print, a glint or a pale object comes alive without the soft edge of its cut showing. Shapes on the background leave and come back, and their holes are refilled from the background, not smeared from their neighbours.
Accents differ from card to card. Not every card gets the same light sweep: each card picks, from its own layout, one accent for its headlines, one turn for its marks and one for its pills, and every element of a kind shares it, so a card stays coherent and two cards rarely match. The same card always gets the same video. Set them in layers.js with fx ({"headline": "sheen|hop|glint", "mark": "spin|flip|wobble|pop", "pill": "sheen|orbit", "texture": "ripple|wind|swirl"}), or per layer with fx and turn.
Textures move as one surface. A fine line pattern over the card (a wave grid, contour lines, a guilloche) is found as many thin, faint, colourless pieces spread across the card; they stay in the plate instead of flying apart as separate shapes (texture in layers.js), and the plate itself is warped in place: rings spreading from the headline (ripple), a wave passing across (wind) or a slow turn around the headline (swirl). The pattern stays calm right behind the type, and the warp is exactly zero at the loop point. Of the 104 eval cards, only ElevenLabs has one.
Special surfaces.
Safeguards from a frame-by-frame review. Any frame of a link preview may be the one people see, so no frame may look broken. Codex reviewed every eval video at nine moments each; these rules came from what it found:
busy): no part of it moves, the camera breathes and the type takes its light. A wall of logos (one size, in rows), a field of dots or the bars of one mark (one colour throughout) is not a screenshot; it is found before any pieces are joined, and a small part among parts that stay stays too. Name a window in the reading to move it.Camera. A card where every element has to hold still is never frozen: the camera pushes in about 3 % and back, plate and layers together. On a graded or pictorial background the whole card breathes: a slow push-in of about 2 % that returns to 1 at the loop point, so background and layers move together and nothing slides against what is behind it. The headline's landing adds a short, damped punch.
Choreography is automatic: elements enter in reading order (rows top to bottom, left to right), visuals arrive with the words rather than after them, small decorations ripple outward from the headline, a wordmark follows its logo, and the whole entrance is compressed to land by about 2 s of the 4 s loop. render_frames.py prints the plan (kind, motion, start time, accents) before capturing.
Style (style in layers.js):
rebuild (default): a quick staggered exit in the first 0.34 s, then everything re-enters.flow (default with --plate): nothing leaves, and every visual keeps moving through the whole loop, each on its own path: drift, a 3D tilt and a slow turn, nearer (bigger) visuals moving further, so the card has depth. Type stays still and readable. Every move is a sine of the loop, so frame 0 is the card and the loop closes on it.living (default when the type sits on a photo or a 3D scene, where no refill behind it looks clean): nothing leaves. Type stays still and readable while light sweeps through it, the camera breathes, decorative blobs flow, a logo turns once, lines redraw. Jed Bridges' og:video cards are the model: the title stays readable the whole time while one or two things move.Energy (energy): calm (smaller moves, no overshoot, no accents), lively (default), bold (more overshoot, plus a faint flare across the card and two drifting glows).
Overrides per layer: kind, motion (use another kind's motion), at (start time in seconds), idle (how much it moves while it lives: 0 keeps it still, 1 is the default, up to 2; in a card that shows a change, keep the before still and let the after move). Top level: fx (above), accent ("r,g,b" for sweeps, stars and rings; otherwise the first saturated text colour, and white type without one gets no sweep), loop.
Every extra (idle, sweeps, rings, glows, punch, liquid edges, the breathing of a graded background) is exactly zero at t = 0 and t = loop, so the loop closes on the approved card.
Tested on the OG images of 104 well-known sites in the repository's eval/ (developer tools, venture capital firms, AI companies and technology companies) (python3 eval/run.py renders and scores all of them; run it after any change to the engine). Where a reading is wrong it is usually one of: a text line containing a pill or avatars, a dense UI screenshot (many small parts), stylised capitals Tesseract cannot read. Fix those with kind in layers.js.
mkdir -p og && cp $SKILL/template/og.html og/ && cp portrait.png og/ && cp icon.png og/
# edit CONFIG at the top of og/og.html (kicker, title lines, highlight line, subtitle, portrait, name, brand, colours)
python3 $SKILL/scripts/render_frames.py og/og.html og/frames
The template rebuilds the card each loop: staggered exit, title words rising out of masks, a portrait that spins in with a ring shockwave, the subtitle springing up with a flash on its last phrase, the brand row sliding in, a light sweep across the highlighted line, then a hold with drifting glows. render_frames.py prints each element's right edge; keep text 40 px or more clear of the portrait.
Each rule came from a real review.
window.render(t) and the capture script calls it for each frame.scripts/encode.sh:
yuv420p, no audio track, +faststart, 1200×630, CRF 19 (raised to 22, 25, then 28 until the MP4 fits 2 MB), Lanczos downscale from 2× captures.Checks that must pass:
check_frame0.py: frame 0 matches the approved still: mean difference under 2, and no local defects (a gap between letters, a missing edge) on more than 0.05 % of pixels.check_loop.py: the jump from the last frame to the first is no bigger than 1.5 normal frame steps (plus 4 levels of slack), and the video moves: some frame differs from frame 0 by a mean of at least 0.2 levels. A card read as a screenshot keeps its parts in place, so its camera breathes instead.check_collide.py OUT_DIR: no two elements that are apart in the approved card touch while they move (closest approach under 3 px, measured on each element's own outline through the transform the template applies, and against what stays in the plate). On a rebuild card only the loop after everything has landed counts. With --fix it calms the moving element (its idle lowered 15 % at a time, recorded in layers.js as fixed) until nothing touches; then render again. A floating orb beside an arrow is the classic case: on Joe Speaking's cards --fix settled the orb at the same idle (0.62) that was chosen by eye.A site's cards usually come from one template (one layout, different words). Treat them as a family:
idle for every card. Then all cards move alike and a fix made on one (an orb calmed) holds for all.og/v/<card>-<sha8>.mp4), never overwrite one, and after uploading check each URL for 200, a 206 answer to a Range request and its sha256.Joe Speaking made 74 og:videos this way, one for every social card in five languages.
<meta property="og:image" content="https://example.com/og/home-v3.jpg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="Plain sentence describing the card">
<meta property="og:video" content="https://example.com/og/home-v3.mp4">
<meta property="og:video:secure_url" content="https://example.com/og/home-v3.mp4">
<meta property="og:video:type" content="video/mp4">
<meta property="og:video:width" content="1200">
<meta property="og:video:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://example.com/og/home-v3.jpg">
<meta name="twitter:image:alt" content="Plain sentence describing the card">
home-v3.mp4), never by query string (home.mp4?v=3). Matching the clean URL style of a site whose preview already played was part of the fix.Apple's players (iMessage previews, Safari <video>) first ask for Range: bytes=0-1 and only play when the server answers 206 Partial Content with Accept-Ranges: bytes. A server that answers 200 with the whole file gets a still image in iMessage, and inline video may not play on iPhone.
curl -s -o /dev/null -H "Range: bytes=0-1" -w "%{http_code}\n" https://example.com/og/home-v3.mp4 # must be 206
worker/range-worker.js and route only .mp4 through it:{
"main": "range-worker.js",
"assets": { "directory": "public", "binding": "ASSETS", "run_worker_first": ["/*.mp4", "/**/*.mp4"] }
}
Without run_worker_first, asset paths never reach the worker. Keep the worker file out of the public folder. Test with wrangler dev: Range → 206, full GET → 200 with Accept-Ranges, out-of-range → 416, other pages unchanged.
Most apps read only og:image. Where video is not supported, the app simply shows your og:image, the approved still, exactly as it did before you added og:video; nothing breaks. The video is a bonus where it plays, which is why frame 0 must be that same image: the still and the moving card always agree.
| App | What it shows | Conditions and source |
|---|---|---|
| iMessage | Plays: autoplays muted and loops | Direct MP4 link; the page under 1 MB, icon + image + video under 10 MB; with autoplay off or Reduce Motion, the still with a play button. Apple TN3156. Needs HTTP Range (206), see below |
| Discord | Plays: inline player with a play button, no autoplay | MP4, WebM or MOV over https; og:image is required and becomes the first frame; the whole fetch must finish within 10 s, at most 50 MB; previews cached about 30 min. Discord's docs also ask for og:type video.other or twitter:card player; a device test (checkmyog, 24 Oct 2026) played a plain website page too. Discord link previews |
| Telegram | Plays: as a looping GIF | Our test on 30 Oct 2026 played the og:video as a looping GIF in the link preview. An earlier device test on 24 Oct 2026 saw only the still (checkmyog), so clients may differ: test yours |
| Slack | Still | Classic unfurls read Open Graph and show og:image; inline video only for sites Slack handles itself or an app unfurl. Slack unfurling |
| X, Facebook, LinkedIn, WhatsApp, Signal, Bluesky, Mastodon, Matrix / Element | Still | Each reads og:image; none plays og:video in a link card (X's large card needs twitter:card summary_large_image). The viral og:video clips on X were iMessage screen recordings |
Sources were read on 2026-10-30; the per-app device tests are from checkmyog (MIT), whose support table cites each one.
scripts/check_live.sh <page-url> reads the page's tags and checks both files: absolute https URLs, a 200 answer with a non-empty body of the right type (image, video/mp4), and the 206 answer to a Range request. It warns about query strings and an MP4 over 2 MB, and exits non-zero on any failure.?t=2).| File | What |
|---|---|
template/from-image.html | Route A: the motion engine; turns layers.js (elements and kinds) into motion |
template/og.html | Route B: configurable HTML card with the full motion set |
scripts/suggest_layers.py | Reads an approved image: finds and classifies its elements, splits type into lines, words and letters |
scripts/make_plate.py | Clean plate, element cutouts and glyph masks (re-run after editing boxes) |
scripts/render_frames.py | Captures frames at 2× through a local server; prints element edges |
scripts/check_frame0.py | Frame 0 against the approved still |
scripts/check_loop.py | Seam against a normal frame step; the video moves at all |
scripts/check_collide.py | No two elements touch while they move; --fix calms the mover |
scripts/encode.sh | Frames to MP4 and frame-0 JPEG, with size limits |
scripts/check_live.sh | Live tags, files, https and Range check |
worker/range-worker.js | Cloudflare Worker adding Range / 206 for .mp4 |
examples/ | Worked examples (route A, living style, route B) with inputs and outputs |
eval/ | 104 real OG images, fetch.py that downloads them, the runner that renders and scores them, and the results |
Other plugins' skills for the same job