Preview Pictures
Why a recording opens on a picture in a player that knows nothing about thermography, which frame that picture is of, and what it costs. The rest of the container is Recording File Format.
The recording chapter is seven pages, each answering one question:
| Page | Question |
|---|---|
| Recording | How do I write a camera to a file? |
| A Running Recording | What is it telling me while it runs? |
| Recording File Format | What is the file, and what may a third party rely on? |
| Preview Pictures | Why does the file open on a picture, and which frame is it? |
| Snapshots and Interval Capture | How do I save one frame, or one every N seconds? |
| Recording Attachments | How do I put my own files inside the recording? |
| Playback | How do I read one back? |
A recording's video track is sixteen-bit temperatures, not a picture. As brightness the whole scene is one shade of near-black (20 °C is 1200 out of 65535), so a perfectly good recording opened in an ordinary player or looked at in a file manager is a black rectangle, or noise, or nothing.
Every recording therefore carries two pictures of the same frame, colorized with the palette and colour scale that recording used, because two kinds of reader need different answers.
| Cover | Notice (placard) | |
|---|---|---|
| For | file managers, thumbnailers, anything that reads attachments | media players, and Windows Explorer |
| Carried as | attachment cover.jpg |
a real video track, one picture repeated |
| Shows | the scene, clean | the scene plus the notice |
| Position | an attachment, not a track | track one, in front of the measurement |
| Size | enlarged enough to be a usable thumbnail | enlarged until the notice is legible and the code scans |
| Disposition | attached_pic |
forced, never default |
| Marked by | its name, the convention | OTC_TRACK_ROLE=placard |
The cover carries no notice text: a folder of two hundred recordings whose thumbnails all read the same sentence is not browsable. The sentence travels with it as the attachment's description. The notice reads:
THIS FILE HOLDS RAW THERMAL DATA OPEN WITH OPTRIS SDK OR CONNECT
In the bottom-right corner is a QR code for https://optris.com/software/. Every build decodes it back out of the finished picture with an independent barcode reader.
The scene owns the frame. Windows thumbnails .mkv by extracting a video frame, so since the notice track became track one this picture is what a folder of recordings looks like in Explorer, with no shell extension installed, and the scene is the only thing that tells two recordings apart. None of the text is legible at that size: a glyph is 14 px tall on the placard, 2.1 px in a 96 px thumbnail and 5.6 px in a 256 px one. The notice is therefore two lines on a thin caption strip, 9.6 % of the frame, with the code in a corner rather than in a band. It was three lines and a band taking 41 %. Measured: 75.6 % of an ordinary placard is scene with nothing drawn on it, 81.7 % on a Xi 80.
The line that went is 16-BIT TEMPERATURES, NOT A PICTURE. otc-meta.json already carries the encoding, unit, scale and offset, and the line is still written out in full in the cover's description.
ffprobe on a recording lists all three roles unambiguously:
Stream #0:0: Video: mjpeg, 640x480 (forced) ← the notice title : Notice: this file holds raw thermal data OTC_TRACK_ROLE : placard Stream #0:1: Video: ffv1, gray16le, 320x240, 30 fps (default) ← the measurement title : Thermal OTC_TRACK_ROLE : thermal Stream #0:2: Subtitle: subrip title : Thermal Metadata Stream #0:3: Attachment: none ← the metadata document filename : otc-meta.json Stream #0:4: Video: mjpeg, 320x240 (attached pic) ← the cover filename : cover.jpg
Read either one back like any other attachment. Player::GetAttachments() on an open recording returns the whole list, each rec::Attachment carrying its name; Player::ReadAttachments(path) answers the same question without opening the file for playback. (There is no Player::GetAttachment(name) on the public Player; the single-name lookup exists one layer down, on rec::Player, which is internal.)
otc-meta.json says what the cover was drawn with, in a cover block beside the attachment index:
"cover": { "name": "cover.jpg", "pts_us": 0, "render": { "palette": "Iron", "range_min_c": 17.91, "range_max_c": 30.90 } }
Use it to put a correct colour bar next to the thumbnail; you cannot work it out otherwise. The file-level render block is the state as the recording opened and carries no range at all under an automatic colour scale, while the cover is drawn from the frame the recorder chose as a real picture, which is not necessarily the first. range_min_c and range_max_c here are always present and are the ends the picture was drawn with. pts_us is where that frame sits in the recording, on the same clock as the measurement track, so you can seek to it.
The block is absent on a recording with no cover, on one whose cover your own application supplied, and on anything written before September 2026.
How long the notice stays up
A player stops when the track it is showing runs out of frames, not when the file's duration runs out. A duration declared on the frame changes nothing, and neither does a long recording behind it. Measured with VLC 3.0.23 against a real, paced video output:
| what the notice track holds | how long VLC stays on it |
|---|---|
| one frame, no duration: what earlier v12 wrote | 0.09 s |
one frame with a five-second BlockDuration |
0.08 s |
| one frame, on an eight-second recording | 0.24 s |
| a frame every second across eight seconds | 6.11 s |
So the notice is the same picture written again once a second, for at most the first three minutes. Each repeat costs its own size and nothing else (no re-encoding, no second picture), about 0.5 % of a 640×480 recording.
The repeats stop where the measurement stops. A recording shorter than three minutes shows its notice for its own length. Nothing is written past the last temperature, so the length the file reports is still the length of the recording.
The notice track declares no frame rate and its blocks carry no duration, which keeps the file's length equal to the measurement's. Stopping the blocks at the last temperature is not enough on its own: a Matroska file's declared length is the end of its longest track, so a notice block declaring a one-second duration would claim a second the recording does not have, and software waiting for a replay to reach a length up to a second too long would wait for ever.
The notice track's packets therefore report duration_time=N/A, except the last, which ffprobe fills in from the rate it works out for itself. Neither affects how long the notice is shown, which is governed by when the next block arrives. Do not read r_frame_rate off this track either: ffprobe works that figure out from the timestamps it sees rather than from anything we write, so it has always reported nonsense here: 1000/1 on the old single-frame track, and something near the repeat rate now. Neither is a change of content. If you extract the notice picture with ffmpeg, ask for one frame (-frames:v 1) or you will be handed every repeat.
Notice forced, measurement default
Two dispositions doing two different jobs. Every combination was measured on ffmpeg 7.1.5 and VLC 3.0.23, in both track orders (T,P is the measurement first, P,T is what the SDK writes):
| order | measurement | notice | plain -c copy keeps |
VLC opens |
|---|---|---|---|---|
| T,P | (none) | (none) | measurement | measurement |
| T,P | (none) | default | notice only | notice |
| T,P | (none) | forced | measurement | notice |
| T,P | default | forced | measurement | both, a near-black frame first |
| P,T | (none) | (none) | notice only | notice |
| P,T | (none) | forced | notice only | notice |
| P,T | (none) | default | notice only | notice |
| P,T | default | (none) | measurement | measurement |
| P,T | default | forced | measurement | notice |
The last row is what the SDK writes, and the only one that answers all three questions correctly.
AV_DISPOSITION_FORCED on the notice is what moves a player: av_find_best_stream() does not weigh it at all, and VLC's Matroska demuxer does honour Matroska's FlagForced when choosing a video track.
AV_DISPOSITION_DEFAULT on the measurement is what keeps a remux honest. It is a first-order key in av_find_best_stream(), ahead of frame count, bitrate and position. Without it, the notice (being in front and larger) would win the selection ffmpeg -i rec.mkv -c copy out.mkv makes with no -map, and that command would silently write out a file holding one JPEG and no temperatures. The build checks that first.
The notice is enlarged until its words are legible and the QR code scans, on every camera. Marking the measurement default wins the remux selection at every relative size, so an enlarged notice never costs a file its temperatures.
The cover keeps its own, much smaller enlargement because it lives in the file header, which a probe reads in full under a 64 KiB budget; the notice's single frame sits past that boundary. Measured: the largest header in the test corpus grew by 31 bytes when the notice went to full size.
Repackaging a recording: use -map 0
ffmpeg -i rec.mkv -map 0 -c copy out.mkv # keeps everything ffmpeg -i rec.mkv -c copy out.mkv # keeps the temperatures only
The plain form keeps one stream per media type and no attachments at all. Your temperatures survive it (the default disposition sees to that), but the notice, the cover and otc-meta.json are dropped together: the result still measures and no longer explains itself. OTC_FORMAT and OTC_SOFTWARE survive either form, which is why they exist. Keep your originals.
What the SDK does with them
Nothing. internal::IsContentVideoStream() takes the track whose OTC_TRACK_ROLE says thermal, or which carries no role at all, which is every recording written before the tag existed. So Player, FrameIndex and SessionPlayer see exactly the thermal tracks they always saw, in old files and new, including a multi-camera session file where several thermal tracks are legitimate and the notice must not count as one more camera. Nothing selects a track by its position, which is what made the order safe to change.
What it costs
Measured on a 640×480 recording with sensor noise in it: 63,301 bytes against a 7,456,965-byte recording, 0.85 %, about a quarter of one frame. Cover 25,563; notice 37,141. The notice is drawn once however long the recording runs. Each of its repeats (see How long the notice stays up) costs 37,141 bytes against a thermal track costing 248,565 bytes a frame, about 0.5 %, and nothing after the first three minutes.
Turning it off. GlobalConfig::write_preview = false on rec::Recorder, or SessionConfig::write_preview = false on a multi-camera session, writes files exactly as they were written before this existed.
What this does not fix
A thumbnailer that decodes a video frame rather than reading cover art resolves to the thermal track and still shows a near-black thumbnail. That is unchanged from before this feature and cover art cannot fix it; it is why the notice track exists for players. Windows Explorer does not read Matroska cover art on its own either: it needs a thumbnail provider, which is what Connect's shell extension is.
Which frame the pictures are of
Not the first frame, and not an arbitrary one. Matroska declares its attachments in the header, before the first cluster, and the header goes down when the first frame arrives, so the cover has to be made out of a frame that exists at that moment. Choosing a later, better one would mean rewriting the finished file, which for a four-gigabyte segment is four gigabytes copied to gain forty kilobytes.
FrameMetadata::thermal_data_reliable documents two distinct states and only one of them can be waited out:
- The first frame or two of a camera are converted before the first non-uniformity correction has a dark reference, so they run off the end of the calibration curve and clamp. Measured: a PI 4x0 read a flat 125.0 °C, an Xi 400 96.9–125.0 °C, in a room at about 25 °C. Colorized, that is one solid rectangle, and exactly what an application that opens a camera and records at once produces first.
- After that the frames look plausible and are a perfectly good picture; they are simply not yet a trustworthy measurement, and that lasts as long as the detector takes to warm: about 18 s on a camera that has been running, four and a half minutes on a PI 4x0 from cold.
So the recorder holds a short look-ahead (at most six frames or 400 ms of capture time, whichever comes first) and takes the first frame that is a picture of the scene: shutter open, and more than one temperature in it. It does not wait for the detector to settle, which would mean holding minutes of the recording in memory. Where the chosen frame is still unsettled the notice gains a fourth line, DETECTOR NOT SETTLED: APPROXIMATE, and the description says the same.
Nothing is held back from the file. Every frame the look-ahead sees is written, in order, the moment it resolves, including a recording that stops inside it, which is a one-frame take or a trigger that fired and cleared. WriteFrame() returns normally for a held frame because the frame will be written, so a caller counting frames is counting the right thing. With write_preview off the look-ahead is never entered at all.
Each segment of a segmented recording gets its own look-ahead and its own cover, so a segment handed to somebody on its own is a picture of itself.
Other properties
- It is drawn with what the recording recorded, not with a default: the palette, the colour-scale ends and the auto-scale mode that were in force. A built-in palette is looked up from its name. Your own is drawn from the 240 colours the file itself carries, the same
palette_colorsany other reader gets. If no colours are available at all the cover falls back to the default palette and its description says so. - No measuring areas are drawn on it, and the description records that rather than leaving it to be inferred: a box or a label on a thumbnail reads as part of what the camera saw. The cover is the scene.
- A camera too small to caption is enlarged by a whole number of pixels until the notice fits: a Xi 80's 80×80 becomes 320×320. Every output pixel is a copy of an input pixel; nothing is interpolated.
- A recording that never receives a frame carries no cover. There is nothing to draw.
The MKV format was chosen for its support of arbitrary codecs, embedded metadata, and attachment storage. Files can be inspected with standard tools like mkvinfo or ffprobe.
A recording can be started by your own Recorder().Start() call or by an alarm rule. There are no separate trigger objects: a Rule whose actions include a RecordingAction records when its state changes, and the rule's input decides what it reacts to.
| Rule input | Records when |
|---|---|
SignalId::Region(slot, field) |
A measuring area's reading crosses the rule's limits. |
SignalId::Pif(channel, SignalField::kDigitalIn) |
A PIF digital input changes state. |
SignalId::Pif(channel, SignalField::kAnalogIn) |
A PIF analog input crosses the rule's limits. |
SignalId::Device(field), SignalId::User(slot) |
A device or application-published signal crosses the limits. |
RecordingAction::mode decides what ends the recording: kWhileActive (the default) stops it when the alarm clears, kFixedDuration stops it after duration (10 s by default), and kStop stops whatever is recording. There is one recorder per imager, so a rule that fires while a recording is already open neither starts a second one nor restarts the first. Files go to directory, or to Recorder().SetOutputDirectory() when that is empty, and then to the current directory; the file name comes from name_pattern ({rule}_{timestamp} by default).
Enable pre-roll as well, and the recording includes the moments before the alarm fired. See the alarm-triggered example on Recording.