
The question I get asked most about Diamond Elite is how the video analysis actually works, so I wanted to write a blog that walks through it. The naive version of video analysis with a vision model is to send the video. You can’t, of course, since the model takes images, so the naive version becomes “send every frame,” and that’s where most prototypes die. A four-second phone clip at 60fps is 240 frames. Sending 240 high-resolution images costs a fortune, takes minutes, blows past context limits, and produces worse analysis than sending a handful, because the signal you care about gets drowned in 230 frames of a batter standing still.
What made Diamond Elite work was realizing that a hitting coach doesn’t watch 240 frames either. A coach watches a swing and mentally checks seven positions, and everything else is transition. If you can find those seven moments and send only those, you get better analysis, in seconds, for cents.
In this post I’m going to cover how that pipeline works, end to end.
Stage One: The Browser Does the Video Work
The first architectural decision I made is that video processing happens client-side. The uploaded file lives on the server, but the frame extraction that feeds the model runs in the user’s browser, against an ordinary HTML video element and a canvas.
For me this was mostly about economics. Server-side frame extraction means running ffmpeg per request, on a container sized for video transcoding, for every analysis. Browser-side extraction uses a canvas the user already has, costs us nothing, and parallelizes perfectly because every user brings their own CPU.
The mechanism is simple, if a bit fussy. You seek the video element to a timestamp, wait for the frame to actually be ready, draw it to an offscreen canvas at a reduced width, and read it back as a JPEG data URL. The fussy part is “wait for the frame to actually be ready.” Setting currentTime doesn’t mean the pixels have arrived. You listen for the seeked event, and then you still wait one animation frame before drawing, because the decoded frame isn’t guaranteed to be painted when the event fires. If you draw too early you capture the previous frame, which in a swing analysis means you silently attribute the wrong body position to the wrong phase.
We also wrap every seek in a timeout. Some codecs, some browsers, and some very large files just never fire the event. I’d much rather have a two-second per-frame ceiling with a warning than a capture loop that hangs forever on one bad file.
Stage Two: Find the Swing
Before we can sample seven phases, we need to know where in the clip the swing is. Parents don’t upload four-second clips. They upload the whole at-bat, or the whole cage session, or a two-minute video where the swing happens somewhere around 0:47.

So the pipeline runs a cheap detection pass first. It builds a filmstrip of thumbnails sampled at roughly four per second, bounded to between 30 and 80 frames, rendered at 120 pixels wide with JPEG quality at 0.6. These are deliberately tiny. They aren’t for analysis, they’re for localization, and a 120px thumbnail is plenty to tell whether a person is in a batting stance or mid-follow-through.
That strip goes to the model with a small token ceiling and one job: return the timestamps where a swing starts and ends. There are two endpoints here, one for “find the single swing in this clip” and one for “find all the swings in this cage session,” because a batting practice video with twelve swings is a different problem from a game at-bat.
The result is a swing window, and everything downstream operates inside it.
Stage Three: Sample the Phases, Not the Video
With a window established, the pipeline samples seven frames at fixed percentage points across it, which line up with the seven phases a hitting coach evaluates:

setup → load → stride → hip_fire → downswing → contact → follow_through
These frames are captured at a noticeably higher resolution than the filmstrip, because now detail matters: hip rotation, hand path, weight distribution, whether the front heel has come down. They’re base64-encoded and sent as a sequence of image content blocks in a single message, with a prompt built from a domain knowledge base that describes what good and bad look like at each phase, in the vocabulary a softball coach actually uses.
The model returns structured JSON with a 1–10 score, a per-phase breakdown, annotations, and drills.
There are two details in that response I want to call out, because both took some work to get right.
Annotations are in percentage coordinates. When the model marks “front shoulder flying open here,” it returns a position as a pair of floats from 0.0 to 1.0 relative to the frame, not pixels. That makes the overlay resolution-independent for free. The same annotation renders correctly on a 4K desktop video player and a 375-pixel-wide phone, with no coordinate math and no device-specific bugs. If you only take one implementation detail from this post, I’d take that one, since it applies to any model output that references a position in an image.
Drills must be executable by a twelve-year-old. The prompt requires every returned drill to have a name, three to four numbered steps a kid can follow without adult help, a specific rep count, and an equipment note. Without that constraint you get “work on hip-shoulder separation,” which is correct, not very useful, and no different from what the parent already read on the internet. Personally, I think of output constraints like this as product decisions more than prompt details.
Streaming, and Why Everything Uses It
Every vision call in the system streams. Full analyses run with a token ceiling of 8192, and detection passes run with far smaller ceilings, because a timestamp pair doesn’t need room to ramble.
Streaming is partly a user-experience decision. A 90-second wait behind a spinner feels broken, and the same wait with text arriving feels like work is happening. It’s also a timeout decision, though. The client is configured with a five-minute ceiling and automatic retries on transient connection errors, and the route handlers extend both the request and response timeouts to match. Large multi-image requests are genuinely slow, and default Express timeouts will cut them off well before the model is finished.
That streaming choice has a consequence I’ll come back to in a later post in this series: anything you wrap around the non-streaming call path doesn’t apply to the streaming one, and that one has real money attached.
The Part Nobody Warns You About
The pipeline above is the happy path, and it works. What I underestimated is how much of the engineering isn’t the model at all. It’s the seek timing and the thumbnail budget. It’s deciding that detection shouldn’t charge the user’s analysis quota, because it runs automatically on page load and a user shouldn’t spend their allowance just by visiting a page. It’s the fact that on a multi-swing cage video, analysis must not auto-run, because firing seven analyses unprompted would consume a free tier in one click.

If I had to guess, the model is maybe fifteen percent of the work. The other eighty-five percent is everything around it that decides whether the fifteen percent is usable.
Getting Started
If you’re building something that puts a vision model in front of real users, here’s what I’d suggest:
- Find the signal before you spend on it. Run a cheap, low-resolution, low-token localization pass to identify the moments that matter, then spend your real token budget only on those. In my experience two-stage beats brute force on cost, latency, and quality all at once.
- Let your domain experts choose the sample points. Seven frames chosen by someone who knows the domain will outperform a hundred frames chosen by an even sampler. Put the expertise into where you look, not only into the prompt.
- Return positions as relative coordinates. Any model output that points at part of an image should be normalized to 0.0–1.0. It gets rid of a whole category of rendering bug before you write it.
- Constrain the output to what the user can act on. Spell out the shape of a useful answer in the prompt: steps, counts, equipment. From what I’ve seen, “correct but unactionable” is the most common failure of a working AI feature.
Next in this series, I’ll get into what happens when the model’s JSON is wrong, truncated, or quietly out of range, and why I think the boundary between “the model responded” and “we saved it” is the most important code in the system.
If you’re designing an AI feature and want a second opinion from people who have shipped one, feel free to contact us.
CB5 Solutions is a Microsoft Solutions Partner specializing in Microsoft Security, Data & AI, Modern Workplace, and Azure Infrastructure.
