OptrisOptrisDocumentation

Documentation/OTC SDK/OTC SDK — C++ API referencev12.0

optris::sdk::rec::StreamConfig

Each stream corresponds to one camera. Pass to Recorder::AddVideoStream().

Public attributes

width

uint32_t width

Frame width in pixels.

height

uint32_t height

Frame height in pixels.

frame_rate

float frame_rate

Capture frame rate in Hz.

thread_count

int thread_count = 0

FFV1 encoder threads (0 = auto).

pixels

StreamPixels pixels = StreamPixels::kThermal16

What this track holds. Defaults to the radiometry, which is what every caller that predates visual sources means.

title

std::string title

Track title, written into the container's per-stream metadata.

Empty leaves the track unnamed, which is what every recording written before this existed has. It earns its place on a multi-camera file: ffprobe on one of those otherwise lists "Stream #0:0" and "Stream #0:2" with nothing to say which furnace door either of them is pointing at.

all_intra

bool all_intra = false

Make every frame a seek anchor, so a cut can land anywhere.

FFV1 is an intra-only codec -- no frame's pixels are predicted from another's -- but libavcodec still writes a frame header and a fresh range-coder state table only every gop_size frames, and marks only those packets as keyframes. At the encoder's default of 12 that makes one frame in twelve a seek anchor, which is the 20 of 240 FrameIndex measures and documents.

With this true the encoder is set to gop_size = 1, every packet is flagged as a keyframe, and FrameIndex::AnchorFor() becomes the identity. That is what makes a clip a packet copy: a cut at any frame needs no decode, no re-encode and no snapping back to the previous anchor.

What it costs, and it is not a percentage: What it costs, and it is not a percentage The overhead is a per-frame constant: measured at 423 to 446 bytes a frame, a frame header and a fresh range-coder state table, independent of the picture's size.

So a percentage is that constant divided by whatever a compressed frame costs, and depends on the sensor and the scene. On a 640x480 sensor it is +0.23 % against the encoder's default GOP and +0.24 % against a 300-frame one; against the 32 to 72 KB a real frame of a PI 450, a PI 640 or an Xi 410 costs it is 0.6 % to 1.4 %. Measured directly on three real recordings it is 0.4 % to 2.6 %, which is the same statement.

On a sensor small enough it stops being negligible -- at 160x120 the same constant is 3.4 % -- so the measurement in ContinuousAllIntra.CostsUnderThreePercentAtARealSensorSize is taken at two sizes and asserts the constant rather than the ratio.

Defaults to false, so a plain Recorder writes the files it always has, byte for byte. ContinuousConfig turns it on by default instead, because clip extraction is the whole point there.

quantize_counts

uint32_t quantize_counts = 0

Round each temperature sample to a multiple of this many counts before encoding. Lossy. Opt-in. Thermal tracks only.

One count is 0.1 K in the encoding the recorder writes ((celsius * 10) + 1000), so the error this introduces is bounded, hard, and known in advance. Measured on 60 frames of 640x480, against the same frames written losslessly:

quantize_counts worst-case error file size
0 or 1 none; the default 100 %
2 0.1 K 81 %
4 0.2 K 62 %
8 0.4 K 43 %
16 0.8 K 27 %

Use a power of two: Use a power of two Not a style preference -- it is worth tens of percent. A step of 4 and a step of 5 have the same worst-case error of 0.2 K, and a step of 5 makes a file 41 % larger (measured at 382x288; 62 % of lossless against 88 % at 640x480). A step of 3 saves almost nothing at all (95.5 %) for the same 0.1 K as a step of 2, which saves 19 %.

The reason is what FFV1 codes: prediction residuals, through a range coder. A power-of-two step is exactly "drop the low bits", which removes entropy and leaves the residual distribution the shape it was. Any other step leaves residuals that are multiples of an awkward number -- more values, less regularly spaced, and the coder spends bits on the irregularity. A non-power-of-two step is accepted, and warned about once, naming the better neighbour.

Why rounding and not a lossy codec: Why rounding and not a lossy codec A recording stores finished temperatures -- no reprocessing on replay recovers what the camera measured -- so a lossy thermal track alters the measurement permanently. The question is therefore not "how small" but "by how much, at most". Rounding answers that with a number: no pixel of any frame can be off by more than half a step, which is checkable and provable, and ContinuousLossy.QuantizationErrorIsBounded checks it.

A transform codec does not have that property, and the gap is not small. The one LGPL-safe encoder that takes 16-bit grayscale at all is JPEG 2000 -- x264 and x265 are GPL and are out, which FfmpegLicence.TheVideoBackendIsNotGpl enforces. Measured on the same 60 frames, at matched file sizes:

file size worst-case error
quantize 4 62 % 0.2 K
JPEG 2000, layer_rate 5 64 % 2.7 K
quantize 16 27 % 0.8 K
JPEG 2000, layer_rate 10 32 % 3.6 K

Thirteen times the worst-case error for the same bytes. The mean is not the problem -- it is the tail, and a tail is exactly what a measurement cannot have: one pixel wrong by 2.7 K is one alarm limit crossed that was not.

And it stays the format it was: still FFV1 GRAY16LE, same scale, same offset, same track roles. Every existing reader -- Player, FrameIndex, VideoExporter, the shell extension -- reads a quantized recording with no change at all.

The file says so: The file says so Set this and otc-meta.json carries a lossy block (LossyMeta) and the container carries an OTC_LOSSY tag that survives a remux. A lossy recording that a reader cannot distinguish from a lossless one is the worst outcome available, so it is not possible to produce one through this field.

visual_jpeg_quality

int visual_jpeg_quality = 0

Encode a visual track as MJPEG at this quality instead of losslessly. Lossy. Opt-in. StreamPixels::kColor8 only.

2 (best) to 31 (worst), as FFmpeg's mjpeg encoder scales it -- the same numbers GlobalConfig::preview_quality takes. Zero, the default, keeps the lossless FFV1 BGR0 track that StreamPixels::kColor8 describes.

This is offered for a visual track and not for a thermal one because of what the two are. A visual track is a picture of the scene for a human to look at beside the measurement; losing a little of it costs some detail in a photograph. A thermal track is the measurement. See quantize_counts for the thermal answer, which is a different mechanism for that reason.

Ignored, with a warning, on a thermal stream: MJPEG is 8-bit and a 16-bit temperature cannot be put through it without first becoming something else.

Recorded in the file the same way, in LossyMeta.