Aspect-correct slicing
Dividing the frame width by columns and height by rows is the obvious
approach, and it is wrong: a Stream Deck key is square, so 16:9 cells
arrive stretched. The frame is cropped to the deck's aspect ratio
first, then divided, so every tile is square and the mosaic lines up.
Zoom is a stack of rectangles
Pressing a key pushes that key's rectangle — in source
pixels, not screen pixels — so the whole deck becomes the inside
of one key. How far it goes is pure geometry: an XL divides by 8
across, so a 720p frame is spent in a single press, while a Mini
(÷3) manages three levels. Past 1:1 the badge reads
interpolated, and the stack refuses a press that would leave
cells with almost no pixels in them.
Two-signal motion
Mean frame difference catches a whole tile changing but a small fast
object averages away to nothing. Changed-area — the share of
pixels moving past a noise floor — catches the small object but
ignores uniform drift. A key counts as moving if either fires, and
that verdict is what decides whether the key is redrawn at all.
Dirty-tile skipping
Only keys that actually changed get redrawn. On a static scene that is
the difference between 32 redraws per frame and none; the
redraws skipped figure in the telemetry panel is measured
live, not quoted. Turn the switch off and watch it fall to zero.
Why these clips and not a live stream
Every frame is read back out of the canvas, so a feed served without
Access-Control-Allow-Origin taints it and takes the
filters and the motion detector down with it. NASA's public asset host
sends the header and honours range requests, so the footage streams in
and stays sliceable. Embedded players and the public HLS endpoints do
neither, which is why they are not offered here.
One algorithm, two runtimes
The grid maths and motion detector exist twice: Python for the
hardware pipeline, JavaScript for this page. They are deliberate ports
of each other, and the Python test suite is the shared specification
for both.
Real hardware path
Off this page, the same pipeline reads a Reolink snapshot endpoint or
any MJPEG stream and pushes tiles straight to a Stream Deck over USB
HID — no polling a folder of JPEGs through a local web server.