Skip to content

All case studies

01 / Case study

Frag Movie: a CS2 demo becomes an edited clip, with the kills landing on the beat of the music

How I built Frag Movie: the demo of a CS2 match becomes highlights and edited clips, with services connected by queues, GPU on demand and a read-only MCP.

Industry
Product for CS2 players
Status
In closed beta
Role
Own product, built by Wenderson Belko
Stack
Next.js · Go · ffmpeg · Chromium · Python (MCP) · Node.js · PostgreSQL · AWS (SQS, Lambda, Fargate, EC2 com GPU) · Terraform · Docker Compose · GitHub Actions
Cover image of the Frag Movie case study

02 / Context

Context

Anyone who plays CS2 and wants a clip of the best moment of a match does it all by hand: open the demo, find the moment, record the screen and edit. The demo is the file that stores the whole match so it can be rewatched inside the game.

Frag Movie is a product of mine and does that whole path on its own. The player uploads the demo, or connects their Steam history so matches arrive without an upload. The system returns the highlights, the standout plays such as an ace, 4 kills in a row or a clutch, in ranked order, and edited clips with slow motion, a kill counter and a vertical 9:16 version. A kill is a frag in the game.

The product is in closed beta: the administrator enables each account, and there is a daily quota of clips and demos. Frag Movie is not affiliated with Valve.

03 / The challenge

The challenge

The hard parts were engineering, not interface:

  • The clip has to be recorded with the real game, and CS2 needs a GPU and a screen.
  • The GPU is the biggest cost. It can't stay on waiting for work.
  • Analysis, recording and editing have different timings and costs, and no request can be lost if a machine goes down halfway.
  • The kill has to land on the beat of the music, and the visual effect has to be editable without touching code.
  • Letting an AI query the matches can't open the database to writes.

04 / The solution

The solution

I built the system as small services connected by queues. The code is the same in Docker Compose on my computer and on AWS, and only the variables change: the queue is ElasticMQ locally and SQS in the cloud, the database is a local Postgres and an RDS in the cloud.

From demo to clip

An analyzer in Go reads the demo and writes rounds, kills and highlights to the database. When the player picks a highlight, a recorder opens the real CS2 on a GPU machine, plays the demo at the right moment and records screen and sound. An editor built on ffmpeg applies slow motion, color, music and intros. It runs in a separate container, because editing needs CPU, not GPU.

The GPU turns on when there is work and turns off after 3 idle minutes. I validated the whole path with a real demo of 29 rounds.

The recorder doesn't wait a fixed time for the demo to open: it watches the game and the screen, discards a recording that came out frozen and redoes it once. If it fails again, the clip fails with a clear message instead of handing the player a loading screen.

A task that does not get lost

The message only leaves the queue after the task finishes. If a worker goes down halfway, it comes back and the task is redone. After 3 failed deliveries, it goes to a dead-letter queue. A known error, such as a corrupted demo, marks the task as failed right away and doesn't retry.

Kills on the beat of the music

The editor analyzes the track: bass below about 150 Hz and the beat grid, with a precision of about 10 ms. The first kill lands at the point where the music explodes. For the others, the editor speeds up or slows down the normal stretches between kills a little. Slow motion and the speed ramp, which speeds the video up before the kill and brakes at the moment of it, don't change. In the end-to-end test, the kills land within 3 ms of the hits in the audio of the final video.

There are 12 tracks in the catalog and 10 editing styles, all with a vertical version and a thumbnail.

Graphics in HTML and CSS

The banner with the player's name and the marks for each kill are HTML and CSS pages. The editor renders them in Chromium, frame by frame, with a transparent background, and overlays them on the video. The backoffice preview uses the same document, so what shows up there is what comes out in the clip. Scripts and external addresses are not accepted.

Read-only MCP

To query matches through an AI assistant, I wrote an MCP server with 8 tools. It reaches the database with a role that can only read and filters everything by the token's owner. The stats live in the database, so the MCP keeps answering after the files expire.

Backoffice, retention and delivery

The backoffice requires a password and 2FA, and the same app code can't be used twice. Demos and clips are deleted 30 days after they are generated. Each download uses a new signed link, valid for 1 hour.

CI runs on every pull request: it checks the infrastructure, builds the site and tests the images, and the editor really renders with ffmpeg. The deploy only runs with all of CI green and has a safeguard: if the infrastructure plan wants to recreate the database or the recording machine, it stops.

How it works inside
From demo to clip in Frag MovieThe CS2 demo comes in by upload or from the Steam history and goes through the queues. It is analyzed in Go, the real CS2 records the stretch on a GPU machine, the ffmpeg editor builds the clip and the player downloads it through a signed link.

Real product screens

Frag Movie backoffice with the 10 editing styles and a preview of each
Name banner and kill mark templates, built in HTML and CSS
Backoffice branding screen: logo over the video, watermark and text templates
Frame of a clip generated by Frag Movie, with the kill counter and the brand in the corner

05 / What is still missing

What is still missing

  • Only one real demo has been tested. Other formats, such as Premier, FACEIT and wingman, may reveal new cases.
  • The fine sync of the kills with the counter and the slow motion still depends on checking against real clips.
  • A demo debug text and the "TrueView" notice still show up in the recording.
  • The Discord bot hasn't been built, and FACEIT matches arrive only by upload.

06 / Results

Results

  • 3 msbetween the kill and the hit of the music, in the end-to-end test
  • 10editing styles, all with a vertical 9:16 version and a thumbnail
  • 8tools in the read-only MCP for querying matches with AI
  • 30 daysof demo and clip retention, with a signed download link valid for 1 hour

Have a similar challenge?

Tell me the problem in the project brief. I reply within 1 business day.