AppStars

Veme, 2015–2016

Veme: a video render service, built in 2015.

Veme was a web app for making video memes. You picked a clip, dropped timed sound effects over it, added a caption and saved. Behind it, a separate render service drove ffmpeg to splice the sounds, freeze frames and captions into a new video, accurate to the sample.

Product
Veme (veme.ninja), our own venture
Industry
Media & brands
Services
Web & SaaS platforms, video and media pipelines
Platforms
Node.js and Express, MongoDB, PHP and ffmpeg, Docker, Azure blob storage
Our role
We designed and built the web app, the render service and the API between them.

The challenge

People wanted to turn a video clip into a meme: a sound effect landing on exactly the right moment, a dramatic pause, a caption at the top and bottom. A browser in 2015 could preview that, but it had no dependable way to re-encode video. The finished file had to be made on a server.

And it had to be exact. An effect that starts at 3.2 seconds has to land at 3.2 seconds, not near it. A "pause video" effect freezes the picture while the sound plays, so everything after it moves later. An effect can run past the end of the clip, so the audio has to grow longer than the video. With several effects, some pausing and some not, every pause shifts every later effect. A timing that drifts by a few hundred milliseconds ruins the joke.

Rendering video is also slow and CPU-heavy compared with serving a web page. Doing it inside the web app would let one long render slow the site for everyone else.

Our approach

We split Veme into two services with a written contract between them. The web app, VN.Web, looked after people, clips, the sound library, comments and votes. The render service, VN.Mixer, had one job: take a JSON description of a meme and produce the video.

The contract lived in a plain text file in the repository, with a sample request and a sample result. That small file mattered. It meant the heavy work ran in its own process, which could be scaled, restarted or rewritten without touching the web app. Docker Compose ran the web app, the mixer and MongoDB side by side, with the mixer in its own container.

What we built

The web app

Node.js and Express with EJS views, MongoDB through Mongoose, and Passport sign-in with local accounts, Facebook, Google and Twitter. It stored users, videos, memes, comments, votes and views, and a seeded library of about 6,400 short sound effects in categories. It had HTTPS redirects, compression, and terms, privacy, cookie and DMCA pages: when people upload and share video, takedown is part of the product.

Audio timeline surgery with ffmpeg

ffmpeg will happily mix two audio tracks, but a meme wants the effect inserted. For each sound, the mixer split the original audio at the start time, joined the three pieces (before, effect, after) with ffmpeg's concat filter and re-encoded to 44.1 kHz stereo PCM. Working uncompressed until the very end kept every cut sample-accurate and avoided compressing anything twice.

That choice matters more than it looks. Compressed audio formats work in frames of many samples and add a short run of padding at the start, so cutting compressed audio lands on frame boundaries and the padding builds up with every join. Decode once to PCM, make every cut there, and encode once at the end, and the timing stays exact however many effects you add.

Freeze frames and a running offset

When a sound paused the video, the mixer grabbed a still frame at the start time, looped it for the length of the sound and spliced that clip into the video. A running pause offset then shifted the start and end of every later effect. Without it, the second effect in a meme would land early by exactly the length of the first pause.

Measure first, then cut

The mixer walked the timeline twice. The first pass only measured: how long the final audio would be, padding the original track with generated silence (aevalsrc=0) for each pause and for any effect that ran past the end. The second pass did the splicing against a track that was already long enough, so the cutting logic never had to grow the track halfway through an edit.

Captions in the same pass

Captions used ffmpeg's drawbox and drawtext filters with enable='between(t,start,end)': a translucent band and white text, top and bottom, shown only for their window. The finished video and a thumbnail went to Azure blob storage, ready to share.

Architecture

  1. BrowserChoose a clip, place sounds, write captions
  2. VN.WebNode and Express; the meme is saved in MongoDB
  3. JSON contractVideo, timed sounds and captions
  4. VN.MixerPHP drives ffmpeg: split, splice, freeze, caption
  5. Azure blob storageThe rendered video and thumbnail, ready to share

The CPU-heavy rendering runs in its own container, apart from the web app.

Results

Under the hood

A web app and a render service, with a contract between them.

What we’d do now

The design held up. The details are where a decade of practice shows.

  • Queue the job, don't wait on it. Today the web app would put a render job on a queue and return straight away, and the renderer would report progress. Each job is keyed by the meme's ID, so a retry after a crash is safe and never produces two videos.
  • Never build a shell command from strings. The 2015 mixer joined strings to make ffmpeg command lines, so caption text a person typed ended up inside a command and a filter expression. Now we pass arguments as arrays and escape filter text properly, so nothing a person types can change the command.
  • Pin the tools and test the output. ffmpeg's behaviour changes between versions. We'd pin its version in the container and keep a small set of known memes whose rendered durations and effect timings are checked on every build.
  • Bound the cost. Limits on clip length and the number of effects make the worst-case render predictable, and temporary files are cleaned up whether a render succeeds or fails.
  • One intermediate format. The old pipeline passed through intermediate files in the codecs we trusted at the time. We'd keep everything in one modern intermediate format and encode once, at the end.

Why it matters now

Most products eventually need a heavy job done away from the web request: a render, a transcode, a report or a model run. Veme taught us to give that job its own service, describe it with a contract, make every step exact and clean up after it.

The same shape now sits around AI models. On the Knowby platform, the self-hosted pipeline that turns a video into a step-by-step guide uses ffmpeg's scene filter to find the cuts before any model looks at a frame. The model is the new part; the render service around it is the part we'd already learned. It's the back end we build in our web and SaaS platforms and self-hosted AI work.

Questions

How did Veme render video?

A separate PHP service drove ffmpeg. It split the original audio at each effect’s start time, inserted the effect, froze frames where asked and drew the captions, then stored the video and a thumbnail in Azure blob storage.

Why keep the renderer apart from the web app?

Rendering video is CPU-heavy. Running it in its own container behind a written JSON contract meant it could be scaled, restarted or rewritten without touching the web app.

Did Veme use AI?

No. Its timing was exact, deterministic arithmetic. The render-service pattern is the one we now put around AI models, such as the self-hosted video pipeline on the Knowby platform.

Can you build a media pipeline like this today?

Yes. We build back-end services for rendering, transcoding and model inference as part of our web and SaaS platform work.

Related

The services behind this work, and more stories like it.

Services

Case studies

Bring us the hard problem.

A 45-minute discovery call with the engineer who'll build it.