Skip to content

viewer: RGB video with raw thermal from one live stream - #100

Merged
tridge merged 3 commits into
masterfrom
pr-viewer-dual
Dec 2, 2026
Merged

tridge merged 3 commits into
masterfrom
pr-viewer-dual

Conversation

@tridge

@tridge tridge commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The live viewer can play SupportProxy's combined stream: a camera's RGB video and its raw thermal stream as two tracks of one live Matroska stream (?live=wss://HOST:PORT/mux/1,3). A new View control chooses:

  • RGB + thermal (default): the video with the raw thermal picture inset at the lower right.
  • RGB: the video alone.
  • Thermal: raw thermal alone, with the thermal tools.

Changing the view shows the other track of the same recording at the same time. The stream is not reopened, and following the live edge carries on.

This needs the SupportProxy change that adds /mux/A,B (ArduPilot/SupportProxy#57). Single-track live streams and files behave as before.

Changes

  • LiveRecorder accepts a head with an FFV1 track and an H.264/HEVC track, numbers each track's frames from zero, reads the video frames' telemetry from their SEI, and marks video frames before a keyframe after a gap as not decodable.
  • The stream's SegmentUID names one run of the proxy's mux. Within a run, anything at or before the last Cluster stored is replay from a rejoin; another run starts a new epoch.
  • LiveSource keeps a frame list per track. frames and its batches are the selected track's, so the rest of the viewer sees one track as before.
  • openVideo() can be given the source it already has, to show its other track at the time on screen.
  • InsetView decodes the thermal track with its own decoder and never delays the video. It shows the newest thermal frame at or before the video frame and fades when that is over a second old.
  • In a recording with both tracks the Palette control colours the thermal picture only.
  • Each video frame takes the scene maximum of the newest thermal frame before it (up to a second old), so the map track is coloured by temperature whichever track is on show.

Testing

  • npm test: 219 passed, 1 skipped. New tests cover the two-track recorder (indexing, both rejoin rules, a new mux run), the live source's track selection and re-attachment, and the inset's frame lookup.
  • Browser suite in Xephyr, before the map temperature change was added: 84 passed, 10 skipped, 1 failed. The failure is tests/browser/thermal-analysis.spec.js:375, a playback-timing assertion that also failed on an earlier branch; it was not re-run on master.
  • In Chrome against a SIYI MT11 (HEVC 1080p30 and raw thermal) through a test SupportProxy, and against a replayed flight (H.264 720p30): all three views, switching while following the live edge, and the palette applying to the inset only.
  • A real 14 s capture of the combined stream fed through the recorder twice, as a rejoin would, stored no frame twice and gave telemetry on every video frame.

Limitations

  • The inset is paired with the video by the stream's timestamps, not the camera's UTC, so it can be a frame or two out.
  • A saved combined recording reopens as a file showing the video track only; the View control is for live sources.
  • Findings and review settings are shared by the two tracks.
  • The inset moves with the picture when zoomed in.

@tridge tridge added the AIReview label Dec 1, 2026
@AP-Review

AP-Review commented Dec 1, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-12-01)

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: REQUEST CHANGES

Reviewed at head 8d173b7aef.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/ap_cameragimbal/100/1.html#prAP_CameraGimbal-100

This adds a combined RGB plus raw thermal live view with a thermal inset, and one inset bug blocks it, with a few timing and pairing issues worth fixing.

Blocking

  1. tools/viewer/src/ui/inset-view.js:35: setSource() never resets busy. If the View changes (or the inset is clicked) while an inset decode is running, which is almost always the case during playback, the stale run() skips clearing it and the inset never shows again until reload. Add this.busy = false; in setSource(), plus a test.

Should fix

  • tools/viewer/src/ui/inset-view.js:48: seeking back while a newer thermal decode is in flight, or to before the first thermal frame, leaves a later thermal frame shown in the inset. Supersede the pending request and hide the inset when no frame is at or before the video time.
  • tools/viewer/src/main.js:661: a track switch resets the timeline origin to the new track's first frame, but the same findings and time anchors are reloaded unchanged, so anchor UTC and finding times shift by the gap between the tracks' start times. Keep one origin for the recording.
  • tools/viewer/src/main.js:668: findings record no track, so a finding marked on the thermal picture is pinned at the same raw pixel on the RGB picture. Store the track with the finding and show it on that track.
Minor (2)
  • tools/viewer/src/main.js:669: changing View while End live is waiting for its final snapshot makes endLive() drop the result, and finalised stops a retry, so the recording stays unindexed (no splat).
  • tools/viewer/src/media/matroska-live.js:290: within one SegmentUID any Cluster at or before the last timestamp is dropped silently. This is correct only if the SupportProxy mux never gives two tracks the same timestamp; a count or warning would show it if that ever happens.

@AP-Review

Copy link
Copy Markdown

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: ACCEPT

Reviewed at head 5a0cd39f2e.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/ap_cameragimbal/100/2.html#prAP_CameraGimbal-100

All findings from the previous review are fixed or narrowed at the new head, and nothing blocks merging.

Since 8d173b7: the inset no longer dies when View changes during a decode, and seeking back no longer leaves a later thermal frame in the inset. Each track now keeps its own timeline origin and findings, and a View change during End live waits until the recording is indexed.

Minor (1)
  • tools/viewer/src/media/matroska-live.js:328: replayed-Cluster drop on rejoin (narrowed, still open as a note). A Cluster of the other track with the same timestamp as the last stored one is dropped silently on a rejoin. That can be a thermal frame or an RGB keyframe. This is harmless while SupportProxy keeps the documented strictly increasing timestamps; a counter or log line would show it if that ever changes.

SupportProxy can serve a camera's RGB video and its raw thermal stream
as one two-track Matroska stream. The live recorder indexes both
tracks, reads the RGB frames' telemetry from their SEI, and uses the
stream's SegmentUID to tell a rejoin of the same stream from a new one.

A View control chooses RGB with the thermal picture inset, RGB alone or
thermal alone. Changing it shows the other track of the same recording
at the time on screen; the stream is not reopened.
@tridge
tridge marked this pull request as ready for review December 2, 2026 02:25
@tridge
tridge merged commit ac59438 into master Dec 2, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants