Build log: turning one photo into a ~13-second racing meme video on Cloudflare Workers
Description and use
An automated service using Cloudflare Workers, R2, and D1 turns a user photo into a 13‑second racing meme video with an original soundtrack, validating the face, managing credits, and auto‑deleting files after 7 days.
Problem
Users wanted to insert their own face into a viral racing meme clip, but existing tools required complex setups and paid services.
Outcome
The pipeline delivers a 13‑second racing meme video from a single photo in about four minutes, with automatic face validation, credit management, and audio handling, all within a single Cloudflare Worker.
Workflow
- 1. User uploads photo and signs in with Google; photo stored in R2.
- 2. Pre‑charge face check verifies exactly one frontal face and rejects tiny faces or errors with a 503.
- 3. Photo and signed reference clip URL sent to the video‑to‑video model; output length matches trimmed 12.8s reference.
- 4. Output duration validated against reference; MP4 timing table rewritten if needed.
- 5. Audio tracks dropped from the model output; original backing track (13.0s with 0.5s fade‑out) merged via ffmpeg endpoint.
- 6. Result stored in R2; user notified via email; video available for download; both audio and silent copies provided.
- 7. Automatic cleanup deletes photo and video 7 days after job completion.
- 8. Credit ledger in D1 tracks usage; daily spend cap and per‑user limits enforced; failed jobs refunded appropriately.
Evidence
The model wants one clear face. If you send a group photo or a profile shot, it still bills you and the result is bad.
The racing reference is trimmed to exactly 12.8s (384 frames; the old shot 5, a blurred close pass, made the rider's face drift) ...
The music is an original backing track generated for the site, not any existing song. It's stored privately in R2 and merged with a hosted ffmpeg merge endpoint.
- Record date: 2026-10-16T19:55:57.579Z