Build log: turning one photo into a ~13-second racing meme video on Cloudflare Workers
Описание и применение
Автоматизированный сервис, использующий Cloudflare Workers, R2 и D1, преобразует загруженную фотографию в 13‑секундный видео‑мем с оригинальной дорожкой, проверяя лицо, управляя кредитами и автоматически удаляя файлы через 7 дней.
Задача
Users wanted to insert their own face into a viral racing meme clip, but existing tools required complex setups and paid services.
Результат
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.
Рабочий процесс
- 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.
Доказательства
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.
- Дата записи: 2026-10-16T19:55:57.579Z