5Dakar → Paris, on the whiteboard · episode 5 of 10
The video stream: live, outage or replay?
On a hitchhiking trip, the mobile connection often drops. When it does, the livestream does not simply stop on a black screen: a waiting screen appears, and it replays earlier moments of the journey.
For our machine, this is a trap. An argument from three days ago, replayed in the middle of the night, looks like an argument happening now: same voices, same tone. If we do nothing, it ends up in the travel log, on the wrong day.
This episode shows how to recognise what is on screen, without artificial intelligence.
Problem: during connection outages, the channel shows a waiting screen that replays clips. Their audio is transcribed like everything else; nothing in the transcript distinguishes live speech from replayed speech.
Solution: an image template to spot the outage screen, an audio fingerprint to recognise the replayed clips, and a label on each speaker turn before the call to the language model. No vision model, no GPU needed for this part.
Independent Veden project, not affiliated with Nico, Ascend or their partners.
Move forward with the arrow → or the Next button. “Discovery / Technical”, at the top, changes the level of the text; “Listen” reads it aloud.
5Recording
The livestream, recorded in ten-minute pieces
Our machine records the livestream the way a viewer would, without interruption, in small ten-minute files.
If it misses a moment, because of a failure or a restart, it goes to fetch it from the replay that Twitch keeps for a few days, and downloads only what is missing.
Streamlink records the HLS stream in .ts segments of 600 seconds, named after their UTC start time. Continuous capture started on 24 September at 00:41 UTC; the first four days were reconstructed from the replays.
On each run, a script finds the gaps between consecutive segments (actual duration measured by ffprobe) over the last three days, and downloads only the missing ranges from the replay. Lost chat is recovered separately, by a second script run on demand, from the replay's replayed chat.
5Outage screens
Two screens that are not the livestream
The first screen appears when the connection is lost: a fixed frame, a waiting message, and in the centre, old clips of the journey.
The second appears when the broadcast crashes: a dark, frozen screen. But note the catch: the sound is sometimes still live. The travellers keep talking, only the picture is stuck.
Two templates, each with its own threshold: the “connection lost” screen, which replays clips in the centre of a fixed frame, and a crash screen on a dark background, during which the audio may remain live.
This difference dictated the architecture: the picture says “the connection is cut”, it does not say what you hear. A detected screen therefore excludes nothing on its own; it is a clue that narrows the audio search.
5Shrinking the image
A small grey image is enough
We could show every image to an artificial intelligence and ask: “is this the livestream?”. But over a month, at one image every two seconds, that would make more than a million images. Expensive, slow, and not always right.
Yet the outage screen is always the same. So we shrink each image to a small grey thumbnail: faces can no longer be recognised, but the frame of the waiting screen remains perfectly visible.
ffmpeg extracts one image every 2 seconds, scaled down to 160 × 90 pixels in greyscale: 14,400 values from 0 to 255, instead of about 400,000 pixels in colour for a 480p image, the quality recorded to spare the disk. At that size a face becomes a blob, but a frame or a banner stay sharp. We ignore the content and recognise the fixed frame around it.
A vision model would have had to examine about 1.3 million images over 30 days. Here, the computation runs on the processor, in one subtraction per image.
5The template
A subtraction and a threshold
We keep a model of the waiting screen, made from a few captures. We only look at the parts that never move: the frame and the message, not the centre where the clips play.
For each image of the livestream, we measure how much it differs from this model. The waiting screen gives a small gap, the livestream a large one. Between the two, the margin is wide: that is why such a simple calculation is enough.
The template keeps the median image of a few captures, and a mask of stable pixels (variation of at most 12 between captures) and bright ones (above 40). Without excluding dark pixels, a black background would look like every night scene filmed on a phone.
The mean gap to the template, over the masked pixels only, ranged from 2 to 30 on the outage screen; on the livestream, it never dropped below about 70. Threshold: 40. A stretch is only kept if it lasts at least 6 seconds.
See the code: recognising a fixed screen with a template
import numpy as np
STABLE, SOMBRE, SEUIL = 12, 40, 40
def gabarit(captures: np.ndarray):
"""captures: stack of 90×160 greyscale images of the waiting screen."""
ref = np.median(captures, axis=0)
masque = (captures.max(0) - captures.min(0) <= STABLE) & (ref > SOMBRE)
return ref, masque
def est_ecran_attente(image: np.ndarray, ref, masque) -> bool:
ecart = np.abs(image.astype(int) - ref)[masque].mean()
return ecart <= SEUIL
5The audio fingerprint
Recognising a clip by its sound fingerprint
During an outage, we need to know whether what we hear is an old clip. To do this, we compute the sound fingerprint of each clip, as an app that recognises a song does.
If the sound heard matches the fingerprint of a known clip, it is a replay. Otherwise, it may be the travellers' voices, live.
Chromaprint (fpcalc) boils the audio down to a series of 32-bit integers, one roughly every 0.12 seconds; each bit compares the energy of two frequency bands. Two recordings of the same sound differ on few bits; two unrelated sounds differ on one bit in two. Similarity is measured by the bit error rate, validated below 0.30.
To avoid comparing every piece with every clip, the values vote: a (clip, offset) pair that accumulates votes is a plausible alignment, then checked bit by bit. The search covers only the outage screens, with 60 seconds of margin before and after.
5The catch
The clip created just before the outage
Viewers often create a clip just before an outage: the moment the picture freezes, a sentence left hanging. Our machine found this clip at the very start of the outage, and took it for a replay.
In reality, it was the clip's original moment, not a replay. The fix comes down to a common-sense rule: a replayed clip must have been created well before we see it again.
The 60-second margin before the screen brought up clips created in the very last seconds of the livestream: same sound, excellent bit error rate, but it was the origin of the extract, not its copy. When checking the matches, 18 out of 197 were in this case.
Fix: a replay is only accepted if the clip existed at least 5 minutes before the moment it is heard; a clip with no creation date is discarded. When in doubt, we prefer to let a replay through rather than remove real live speech.
matches that were the original moment
18 / 197
were the clip's original moment; the minimum-age rule of 5 minutes discards them.
5What the model sees
Removing rather than warning
Before sending ten minutes of the livestream to the artificial intelligence that writes the travel log, we sort it. Replays are removed: it never sees them, so it cannot tell their story.
What was said during a frozen picture is kept, with the note “picture cut, sound live”.
Each speaker turn is given the state of the picture at its midpoint: livestream, type of outage screen, or replay. In the request sent to the model, replayed turns are removed, turns spoken during a screen but not recognised are kept with the note “picture cut, sound live”, and the header states the picture state of the slice.
Removing rather than annotating: an instruction like “ignore passages marked replay” depends on the model's attention, slice after slice. A missing line cannot be misread.
5Summary
What to remember
- During outages, the livestream replays old moments: we have to recognise them.
- For a screen that does not change, a small grey image and a subtraction are enough.
- A sound fingerprint recognises replayed clips, as an app recognises a song.
- A replayed clip must exist before we see it again: 18 matches out of 197 were in fact the original moment.
- A fixed-target problem is solved with a template, a mask of stable pixels and a measured threshold.
- The picture narrows the search; the audio fingerprint decides; the screen alone excludes nothing.
- An exact match is not proof of meaning: it took a date to tell the original from the copy.
- Remove the replays from the request rather than ask the model to ignore them.
Do you have hours of video to sort through?
Recognising a screen, a jingle or a known sequence can often be done without AI, faster and cheaper. Write to me: we will look together at what is feasible.
Let's talk about your project