# Turning my home ADS-B receiver into a 24/7 live-stream screen: from a 5-minute delay down to zero

> The site deliberately never stored aircraft coordinates. Making the receiver a live OBS-to-YouTube screen meant releasing positions: a delay going 5 min, 1 min, 0, a canvas/CSS variable trap, OBS WebSocket volume.

- Date: 2026-11-29
- Topics: Radar, Next.js, Privacy
- Chinese original: https://kbs0830.com/blog/radar-live-stream-delayed-positions

The [home radar](/radar) page (in Chinese) has had one rule from the start: **numbers only, no positions**. How many aircraft right now, how many today, which airlines: all fine. Aircraft coordinates and how far they are from the receiver are never stored. The reason is simple: if you draw the positions of the aircraft the receiver picks up, the center of the circle is the receiver, which is my home.

Later I wanted to turn it into a 24-hour YouTube live stream, using OBS to capture a web page as the picture. A stream without a map and aircraft is not much to look at, so the rule had to loosen. A lot changed that day, and I record it in time order: every relaxation was my own decision.

## The initial rules: delay first, do not mark the receiver

- I can say **roughly Kaohsiung**, and nothing finer.
- Aircraft positions may be shown, but **delayed by 5 minutes**: they cannot be used for real-time tracking, and it is hard to work out the reception range from "which aircraft can be received at this moment".
- The map is fixed on the Kaohsiung area, **not centered on the receiver**, with no distance rings and no receiver marker.
- The rules for the other pages (`/radar`, `/api/radar`) are completely unchanged; the only things that release coordinates are one new API and one new page.

Later all of these numbers changed, but the approach of "the rule is written at the data exit and the numbers live in constants" never did: change one `DELAY_MS` line and the delay goes from 5 minutes to 1 minute and then to 0.

## How the data flows

The site's server already reads the receiver on a timer. I added a `radar-live.js` that, after each read, also stores each aircraft's current position, speed and heading in `data/radar-track.json`, **keeping only the latest 20 minutes** and discarding anything older.

The public `/api/radar/live` only gives samples from before "now minus the delay". A unit test checks exactly this: build a series of samples and confirm that nothing newer than the cutoff appears in the output.

Other handling:

- **Identifiers do not leak.** The ICAO hex that the receiver returns is the aircraft's identifier, and the API returns only a short HMAC code whose key is regenerated on every start. At first I hashed "hex plus date" directly, and only later realized that a hex is just 24 bits, so a plain hash can be brute-forced; hence HMAC.
- **Registration, owner and manufacturer are given only for commercial flights with a normal flight code.** The owner of a private aircraft may be an individual's name, so a flight without a flight number gets none of these fields.
- **Coordinates are rounded to three decimal places**, about 100 meters.

## Delay to 0, and receiver reads from 30 seconds to 2 seconds

After the stream started, I first cut the delay to 1 minute, then decided to go straight to 0. With a delay of 0 and one data point every 30 seconds, aircraft would jump along, so the sampling changed too. I first made it 5 seconds, then felt it was still not live enough and cut it to 2 seconds:

- The server's receiver read went **from 30 seconds to 2 seconds** (the stats and the live-stream track share the same read); the track keeps 20 minutes, and the entry cap went from 300 up to 700.
- Looking up aircraft types on the external adsbdb did not speed up with it: it runs once every 15 reads (about 30 seconds), or the request volume would be 15 times higher.
- The screen asks the site for data every 2 seconds and draws on a canvas, with the playback time set to "now minus the delay minus a short buffer" (the buffer shrank from 10 to 4 seconds, so the picture is only 4 to 6 seconds behind the real aircraft position), interpolating linearly between two samples and, with no newer sample, extrapolating from speed and heading for up to 75 seconds. The trail draws the latest 5 minutes, fading with age.

The same day I also removed the filtering of low-altitude, on-ground and unknown-altitude positions. The original rule was that low-altitude tracks reveal how close the aircraft is to the airport, and therefore to the receiver, so only positions with a known altitude of 1,000 ft or more were released (at one point I wrote "unknown altitude passes", and the automatic security check pointed out that this fails open, and I changed it to fail closed). Later I decided the screen should show everything, so that rule was dropped, along with its tests.

The rules that remain: the map is not centered on the receiver, has no distance rings and no receiver marker; the center of the scan line sits in urban Kaohsiung, only for atmosphere and not data.

## Aircraft without coordinates

Once I noticed two flights that did not appear on the screen. Looking at the data showed that the receiver had heard them (today's stats counted them), but had only received part of the signal and did not decode a position, so the map could not draw them. Such an aircraft, as long as it has a normal flight number, now appears in the right column's "Just passed", just not on the map.

The "Just passed" records are kept for 24 hours with no entry cap, and the screen shows as many rows as fit the block height, never cut in half.

## The coastline and county borders without a map service

I did not want the base map to depend on an external map service (a stream has to be stable, and I did not want a pile of map-data licence text on the screen):

- Coastline: Natural Earth 10m land data, clipped to the Kaohsiung area with Sutherland–Hodgman and simplified with Douglas–Peucker: 32 polygons, about 700 points, 11 KB.
- County borders: g0v's taiwan-atlas, taking only the internal boundary shared by two counties (the coastline is already there), 8 KB, drawn as a dashed line.
- Airports, runways and navaids: OurAirports (public domain).

I hit one small trap when clipping the coastline: for a closed ring whose first and last points coincide, Douglas–Peucker finds every point at distance 0 from "this line", so the whole ring is simplified down to 2 points and not one polygon survived. The fix is to cut the ring into two segments in the middle, simplify each, and join them back.

## Canvas `font` does not understand CSS variables

The city names and flight labels on the map did not react at all to any size change at first. The reason is that I had written:

```ts
ctx.font = `17px var(--font-mono), monospace`;
```

The canvas `font` property **does not resolve CSS variables**, so the whole line is invalid and the browser silently ignores it, leaving the font at the default 10px. You have to read the real font name first with `getComputedStyle(canvas).getPropertyValue("--font-mono")` and then build the string. There is no error message for this; I only noticed from screenshots, asking why the text had not grown.

## OBS is not a visitor, and does not refresh itself

The site has a visit counter and a "N people right now" indicator (shown in Japanese style). OBS's browser source stays open forever, and unhandled it would count as one permanently online visitor. The stream page skips those two reporting components directly; the page is also `noindex`, blocked by robots, and not in the sitemap.

Another problem is that OBS's browser source **does not refresh itself**: every time I deployed a new version, what ran inside OBS was still the old one. The fix is for `/api/radar/live` to return a `build` (the commit of this deploy); the screen remembers the first value it sees and, when it changes, calls `location.reload()` on its own after a random 0 to 8 seconds. The old screen lacks this code, so the first time it had to be refreshed by hand, and after that it updates itself.

## The volume bar: OBS browser source cannot read the microphone

The stream plays music, and I wanted a volume bar on the left of the screen so people can see that there is sound. The first version used the browser's `getUserMedia` to read an "audio input", together with a virtual audio cable (VB-Cable): the music player outputs to the virtual cable, and both OBS and the web page read that cable's output.

It worked perfectly in a normal Chrome, and in OBS's browser source it was `NotAllowedError: Permission denied`: the browser embedded in OBS does not let web pages read the microphone. So I took another route:

- OBS has a built-in WebSocket server (Tools → WebSocket Server Settings); subscribing to the `InputVolumeMeters` event gives continuous reports of the volume of every source in the mixer.
- The page connects to `ws://localhost:4455`, goes through Hello → Identify (with a password, authenticating with `sha256(sha256(password+salt)+challenge)`), reads the volume of the source with the matching name, converts it to dBFS and draws it as 24 segments.
- No microphone permission needed, and no virtual audio cable either.
- The site's CSP allows `connect-src ws://localhost:*` for this page only, and the microphone Permissions-Policy is likewise opened only for this page, with every other page still fully closed.

There was no real OBS during testing, so I used Playwright's `routeWebSocket` to simulate OBS's messages in the page, covering four cases: no password, correct password, password not given, and a mistyped source name.

## Deploying: from 5–7 minutes to a bit over one

The stream picture kept changing, and waiting for deploys got annoying. I measured where the time went:

- A push triggers E2E and the deploy at the same time, and the whole site has only one self-hosted runner, so the deploy queues behind E2E (about 5–7 minutes). **After making E2E manually triggered, the deploy took only about 70 seconds.** (The cost is that no E2E guards a push, so changes have to be verified on a test port first.)
- Of the remaining 70 seconds, compiling took 20. The log kept saying `No build cache found`: before every build, `deploy.ps1` deleted the entire build folder, including the compile cache Turbopack keeps inside it. I changed it to clear everything except `cache`, and with the two build slots alternating, each slot's cache is usable every other deploy.

## When there are no aircraft: the carousel and the METAR translator

Kaohsiung airport has a curfew, and in the middle of the night there are often whole hours without aircraft, leaving only "airspace quiet" on the screen. I changed the idle screen into a carousel of four cards: Kaohsiung departures, Kaohsiung arrivals, current weather, and the radar data of the past three days; the background is blurred and dimmed, and it switches back to the map the moment an aircraft appears.

On the "current weather" card I put the original **METAR report** for Kaohsiung airport, followed by a plain-language translation, because a METAR is itself the most accurate weather data for an airport. That translation later also became a small tool on the site, the [METAR translator](/tools/metar) (in Chinese): pure rule matching, offline, no AI; a pasted report is decoded only in the browser, and fields it does not understand are marked as they are rather than guessed. The reports come from public data of the NOAA Aviation Weather Center, fetched by the server every 5 minutes. One detail while writing it: what follows `BECMG` and `TEMPO` is forecast, and it must not be used to overwrite the "current" wind and visibility.

## Offline means look at the data, not at the status

Once, in the early morning, the right column already listed flights while the map was still stuck on the blurred, dimmed "receiver temporarily offline". The cause was two inconsistent kinds of "offline":

- The site's `online` looks at the state of the FR24 feeder program on the receiver (whether it is connected, or stuck in shutdown).
- But the aircraft on the map come from another program, dump1090, which can keep receiving aircraft while the feeder is stuck.

When the two are out of sync, the screen says "offline" and shows aircraft at the same time. The check is now: **if aircraft are moving on screen, it is not offline**; only when the site cannot be reached, or the status is offline and there really is not a single aircraft, does it go to the offline screen. I intercepted the API with Playwright, fed it data of "status offline but aircraft present", and confirmed that the screen shows the full map directly.

I also added a self-rescue: if the screen fails to get data for 40 seconds in a row, it reloads itself, with at least 60 seconds between two reloads. Hanging on OBS for 24 hours with nobody watching, it cannot get stuck on an old screen.

## Explanations for viewers

Viewers of the stream will want to know where the data comes from, so the [home radar](/radar) page gained "how to watch the 24-hour stream" and "how the numbers are computed", the [receiver project page](/projects/fr24-receiver) gained the hardware, the stability and how the stream picture is made, and below the [METAR translator](/tools/metar) I added how to read each field, a table of aviation weather categories, common abbreviations and FAQs. All four links in the stream description have enough content behind them to read.

## What I learned

- Put the privacy rules at the **data exit**, not only on the screen side. What eventually becomes public is the API output; how the screen draws it comes later.
- Rules change: the delay went from 5 minutes to 1 minute to 0, and the altitude filter was dropped too. Putting numbers in constants and the rule at the top of the file makes changes less likely to miss something.
- "Can this environment do it" must be verified in the target environment: the microphone works in Chrome and not in OBS, and you only know by seeing the error text in OBS. The diagnostic text (`NotAllowedError`) is far more useful than guessing.
- For a state like "offline", look at the actual data and do not trust only a flag some program reports; when two sources are out of sync, go with what the user can see.
- When a deploy is slow, first measure where the time goes: more than half was queueing, and part of the rest was throwing away a cache that could have been kept.

---

Author: PINGWEI LI (李秉威, Li Ping-Wei)
Original page: https://kbs0830.com/en/blog/radar-live-stream-delayed-positions
