· entry 3 of A software factory builds a media server

Rust, Godot and the first numbers

So far: 65 messages from me · about 6 h of my time · 120 agent-hours · about 24 € · 13,000 SLOC*

Four days in, the server decodes and draws video and has had its first frames from a game engine. I find it remarkable how far this is already.

Two choices shape most of what exists.

The first is the language. The server is written in Rust. Its compiler refuses whole kinds of mistakes before a program ever runs, for example two parts of a program changing the same memory at the same time. Nobody reads this code, so the compiler is the one reviewer that checks every line. Media servers usually lean on large existing libraries written in C and C++. Here those parts are written again in Rust wherever that makes sense. With AI agents doing the writing, that is a smaller job than it sounds.

So the server has its own reader for video files and its own decoder for HAP, a video format made for media servers, where the graphics card does much of the unpacking. HAP is simple by design, so the decoder is not the hard part. The check is. Every picture the graphics card draws is compared pixel by pixel with a slow and simple version of the same decoder, and they match.

All of this runs on modest hardware: a Linux workstation with no graphics card of its own, only the graphics built into its processor, and a Mac mini M2 with 8 GB of memory. I decided to go as far as possible without buying test machines. Right now that slows the work down quite a bit.

First numbers, from test clips rather than real footage. On the Mac mini, the server decodes and draws 4 × 4K HAP Q at 60 fps. The slowest step, the graphics card, uses about 11 ms of the 16.7 ms a frame has. Playing them continuously from disk to a screen is not measured yet. The Linux workstation needs a little more than a whole frame for one.

The second choice is game engines. An engine renders what a video file cannot: real-time 3D scenes, content that adapts to what happens in the room, and generative content that is made as it plays. Games are possible too, but they are not the main point. The plan uses Godot and Unreal, which both run on Mac and Linux. The server is in charge. It owns the show clock and the cameras and tells the engine which frame to draw for which moment. The engine runs as a separate program, so if it crashes, the show carries on.

Godot comes first. On November 23 the factory had Godot draw frames that a test program, standing in for the server, took straight from the graphics card’s memory without copying the picture. 600 frames out of 600 came through, on both machines.

None of this is on a screen yet. That is the next step. I have not checked these results myself. They come from the factory’s own tests and measurements.

* SLOC: source lines of code. The server’s own code only; tests, comments and blank lines are not counted.