
Og.video – generate og:video tags that make iMessage previews fun [free/OSS]
URL params in, a streaming MP4 out. A Rust compositor and x264, both in wasm, render each frame inside a Cloudflare Worker and stream the file out faster than it plays. iMessage, Slack and Discord play it inline.
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
URL params in, a streaming MP4 out. A Rust compositor and x264, both in wasm, render each frame inside a Cloudflare Worker and stream the file out faster than it plays. iMessage, Slack and Discord play it inline.
<!-- that's the whole integration --> <meta property="og:video" content="https://og.video/v1/title-card.mp4?title=We+shipped+it&kicker=Launch&brand=ACME&url=example.com"> <meta property="og:video:type" content="video/mp4"> <meta property="og:image" content="https://og.video/v1/title-card.png?title=We+shipped+it&kicker=Launch&brand=ACME&url=example.com">Build a URL Star on GitHub Self-host
100 to 200 msto render a 7 s card
~2 mson a cache hit
38 MBcompositor + encoder, in wasm
9:41
3
M
Maya
Today 9:41 AM
did the launch post go out?
just now. here's the preview
We shipped it
example.com
Delivered
whoa how did you do that
iMessage
Direct video compositing, in a Worker
A scenario is a pure function of (params, frame). The pipeline runs it once per video.
GET /v1/kinetic.mp4?text=… ──► edge cache hit ───────────────────────────────► MP4, ~2 ms ──► R2 hit ───────────────────────────────────────► MP4, streamed ──► miss:
- write the prefix: opening frames, pre-encoded once per prefix key
- render the rest live, one fMP4 fragment per frame GSAP timeline ──► Rust/wasm compositor (tiny-skia + SIMD) ──► x264 (wasm) ──► moof/mdat ──► you
- store the finished file in R2 + the edge cache
Rust compositortiny-skia with SIMD, compiled to wasm. Rasterizes shapes once, restores cached layers by memcpy, converts to I420 and flags the 16×16 blocks that changed.
x264, in wasmEncodes only the macroblocks the compositor flagged. A still frame costs almost nothing.
Streams ahead of playbackThe prefix ships on the first byte. The live tail renders 10 to 30× faster than realtime, so the player never waits.
Renders onceCache key: content hash of the params + scenario version + engine version. Finished files live in R2 and the edge cache. iOS byte ranges come from the cached file.
15 scenarios
Each one is live. Edit the fields and the URL updates; fields left at their default stay out of it. Arrays and objects are JSON.
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。