optris_sdk_recording_options
Everything a recording can be asked for as it starts.
Call optris_sdk_recording_options_init() first; see the struct_size convention at the top of this header.
Public attributes
struct_size
uint32_t struct_size
Set to sizeof(optris_sdk_recording_options).
duration_ms
uint32_t duration_ms
Stop by yourself after this long, in milliseconds. Zero means run until stopped. The clock starts once the recording is live, after any pre-roll has been written out.
max_segment_duration_ms
uint32_t max_segment_duration_ms
Close the current file and open the next one after this much recorded time, in milliseconds. Zero disables it. Values below one second are raised to one second.
reserved0
uint32_t reserved0
Padding, so max_segment_bytes is 8-byte aligned on every platform. Set to zero.
max_segment_bytes
uint64_t max_segment_bytes
Close the current file and open the next one before it would pass this size, in bytes. Zero disables it.
This is what makes a long recording survive a destination that caps a single file: a lossless recording of a 640x480 sensor passes 4 GiB in well under an hour. Set it to whatever that cap is and the recording rolls over instead of dying at the boundary. Any number is accepted -- this is not tied to a file system.
A ceiling for the finished file, trailer included. A part that has been rolled over is never larger than this. The recorder projects what the part will hold -- the open Matroska Cluster, libavformat's interleaving queue, the frame about to be written, and the Cues the trailer puts down -- and rolls over while all of it still fits, rather than comparing the position it has reached against the limit.
It did the latter until v12, and a part therefore ended past the limit by everything written after the last check: measured, 1.6 MB past a 4 GiB limit on a PI 640i, and 31 % past a 1 MiB limit on 160x120 noise. You no longer need a margin of your own for the recording itself, and no fixed margin would have been enough: the Cues grow with the part's frame count at about 24 B a frame, so they consume 4 MiB on their own at about 172,800 frames. A margin for an attachment you intend to add afterwards is still yours to leave.
A part can finish somewhat under the limit, because the projection is an upper bound.
all_intra
int32_t all_intra
Non-zero makes every frame a seek anchor, so a clip can later be cut at any frame with no re-encode.
The cost is a per-frame constant -- measured at 416 to 460 bytes, a frame header and a fresh range-coder state table, independent of the picture -- which is +0.66 % on a 382x288 sensor and +0.23 % on 640x480. Zero keeps the encoder's default, which makes one frame in twelve an anchor.
quantize_counts
uint32_t quantize_counts
Round each temperature sample to a multiple of this many counts before encoding. Lossy. Opt-in. Zero or one records exactly, and is the default.
One count is 0.1 K, so the error is bounded and known in advance: no sample of any frame moves by more than half a step. Measured against the same frames recorded losslessly, on 640x480:
| counts | worst-case error | file size |
|---|---|---|
| 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. A step of 5 has the same 0.2 K worst case as a step of 4 and makes a file 41 % larger, because the compressor codes prediction residuals and a power-of-two step is exactly "drop the low bits".
A recording stores finished temperatures, so this alters the measurement permanently -- which is why the file declares it, in otc-meta.json and in an OTC_LOSSY container tag that survives a remux.
visual_jpeg_quality
int32_t visual_jpeg_quality
Quality, 2 (best) to 31 (worst), for encoding a visual track as MJPEG instead of losslessly. Zero, the default, keeps it lossless.
Ignored on a thermal track, with a warning: MJPEG is eight bits a sample and a 16-bit temperature cannot go through it and still be a temperature. Use quantize_counts there.
reserved1
uint32_t reserved1
Padding, so min_free_bytes below is eight-byte aligned.
Spelled out rather than left to the compiler, the same way reserved0 above is: the .NET mirror is hand-written and DotnetMirrorGuard compares the two side by side, declared leaf for declared leaf. Implicit padding on one side and an explicit field on the other is a disagreement it reports -- and it did, on the first run after this field was added.
min_free_bytes
uint64_t min_free_bytes
Refuse to start at all if the destination has fewer than this many bytes free. Zero, the default, does not check.
The same name, unit and "0 is off" convention as optris_sdk_continuous_config::min_free_bytes, deliberately -- one concept, one spelling.
Honoured by the three optris_sdk_imager_start_recording* calls and by an alarm rule's recording action, which is the point: a rule starts the camera's recording on the SDK's own action thread with no application call in front of it, so an application that refuses its own starts on a nearly full disk still had an alarm start one behind its back. Set it on ::optris_sdk_rule_action's recording options to cover the rule.
A start refused this way returns OPTRIS_SDK_ERROR_INSUFFICIENT_SPACE and the message names what was free and what was required. A rule's refusal arrives on optris_sdk_action_error_fn instead, that being the only channel a rule's action has.
It is a floor at the start only: nothing stops a recording that has already begun, and no headroom is added to the comparison. A continuous recording is the other case -- it has a retention window to trade against, so it prunes and can stop; see optris_sdk_continuous_config.
Appended last, so a caller built against an earlier header keeps the offsets it knows and gets the old behaviour from a zeroed field.
hold_open_across_reconnect
uint8_t hold_open_across_reconnect
Hold this recording open across a camera outage, instead of stopping it when the SDK re-opens the camera. Non-zero to hold open.
Zero, the default, is what every recording has always done: a reconnect is a re-open, so the file is finalized before the teardown and OPTRIS_SDK_RECORDING_STOPPED arrives carrying OPTRIS_SDK_RECORDING_STOP_RECONNECT. An application that wants a second file opens one when it sees OPTRIS_SDK_RECONNECT_RECOVERED.
Non-zero keeps the recording running: the file stays open, optris_sdk_imager_is_recording() stays non-zero, and the frames from after the re-open go into the same file as the frames from before it -- with a marker of the gap written into the file on the first frame that arrives afterwards, which a replay reads back through optris_sdk_imager_get_recorded_gap().
Which to choose, because neither is free: Which to choose, because neither is free Stop is the honest default. An outage has no known length -- the SDK waits for an absent camera indefinitely rather than exhausting its budget -- so a held-open file can be a recording that looks live for hours and contains minutes, and optris_sdk_recording_options::duration_ms keeps running through an outage it cannot capture, so the requested duration is not honoured either way. Hold open is right when one file per shift matters more than each file being contiguous. The hole is in the file either way; this decides whether the file boundary is in it too.
The question is spelled "hold open" rather than "stop on
reconnect" so that the historic behaviour is the zero, which is this struct's rule for an appended field -- see min_free_bytes above. Spelled the other way a caller that zeroed its options would silently have started getting held-open files.
Appended last, same rule as min_free_bytes: a caller built against an earlier header keeps the offsets it knows and gets the old behaviour.
reserved2
uint8_t reserved2[7]
Padding, so the layout is explicit rather than implicit.
DotnetMirrorGuard compares this struct with its managed mirror leaf for leaf, and implicit padding on one side against an explicit field on the other is a disagreement it reports -- which is what reserved1 above records happening the first time a one-byte field was added here.