OptrisOptrisDocumentation

Documentation/OTC SDK/optris_sdk — Python API referencev12.0

RecordingStats

class optris_sdk.recording.RecordingStats

What the current -- or last -- recording did with its frames.

Reset when a recording starts and kept after it stops, so the totals are still readable once the file is closed. Without this, a recording that has silently stopped growing looks exactly like a healthy one.

The accounting rule. Every frame the recording was offered is either in exactly one of the four counters or still in the write queue::

offered == frames_written + frames_lost + queue_depth

The last term is what makes it an identity rather than an approximation while a recording runs: a frame is accepted on the camera's thread and accounted for by the thread that writes it.

A recording ended at its limit by SEGMENT_LIMIT_STOP_RECORDING (12.0.28) ends with the frame that reached the limit: that frame, and any already queued behind it, arrived after the file was finished and, like a frame that arrives after a stop, are in none of the counters.

    rate = ((b.bytes_written - a.bytes_written) * 1e6
            / (b.bytes_written_at_us - a.bytes_written_at_us))

which is the rate between two Cluster closes whatever the
polling rate. Monotonic and not a date: only differences mean
anything, and the epoch is the host's rather than this
recording's. Zero until the first Cluster closes. The trailer
at the stop is a step like any other, so a rate taken across a
stop is the trailer's and not the recording's. The bytes it is
timed against are everything in the file, the cover and the
notice blocks included.
  • Attribute frames_written — frames the recording has taken into the file. A frame counts here once the container has accepted it, which is a moment before its bytes are necessarily on the disk: the container holds packets back so that it can interleave the file's streams. So this answers "did the recording get my frame" and is not a statement that a reader opening the file at this instant would find that frame in it. optris_sdk.camera.Camera.stop_recording is what makes the file complete, and it is a barrier.
  • Attribute frames_dimension_mismatch — frames refused because they were not the size the file was opened at. A mode switch mid-recording produces these, and every one is a frame missing from the file while optris_sdk.camera.Camera.is_recording still reports True.
  • Attribute frames_write_error — frames lost to a write or encode failure -- a full disk, a removed drive, an encoder error. Includes whatever was still queued when the failure ended the recording.
  • Attribute frames_dropped_backlog — frames the recording was offered and did not store, because the writer could not keep up with the camera. This is the counter a slow target shows up in. The newest frame is dropped rather than the oldest, which keeps the file contiguous, so a gap in a recording is always a gap in time. Non-zero means the target cannot sustain this camera. It used to be "zero unless pre-roll is used", which was true of the code and was the hole in it: a recording to a USB stick that kept 58 % of its frames reported 47,887 written and none lost.
  • Attribute bytes_written — the size of this recording's files so far -- every part of a split recording, and each finished part's trailer, included. It is the file on disk, not something ahead of it: every write ends in a flush, so read between two writes this equals the files' size exactly, and it never goes down at a roll-over. What it lags is frames_written, by up to one Matroska Cluster -- it grows when the muxer closes one, which at FFV1's default 12-frame keyframe interval is a step every 12 frames, and at 5 MiB or 5 s at the latest. At a file's start it lags by the cover's look-ahead too, up to six frames or 400 ms. For a rate, pair it with bytes_written_at_us.
  • Attribute last_error — the most recent write failure, or ''. Kept rather than only counted, because "3 frames lost" and "No space left on device" answer different questions.
  • Attribute queue_depth — how many frames are waiting to be written right now. A depth near zero is a target with room to spare; one near queue_capacity is a target about to start dropping frames, so an application can warn before any frame is lost. With a pre-roll, compare the live figures instead: subtract queue_preroll from this and compare the remainder against queue_live_capacity.
  • Attribute queue_peak — the deepest the queue has been during this recording. What queue_depth cannot tell a caller that polls: a stall of a second at 32 Hz fills and empties the queue between two polls a second apart, and this is the only trace it leaves. Read it with queue_preroll_peak, for the same reason queue_depth is read with queue_preroll: on a pre-rolled recording a peak near queue_capacity is the handover, on any other it is a drive falling behind, and this figure alone cannot tell them apart.
  • Attribute queue_preroll_peak — the most of the queue that was ever the pre-roll handover. Zero for a recording started without a pre-roll; otherwise the size of the handover, because a handover is at its largest the instant it is made. A queue_peak equal to this is fully accounted for by the handover, and one well above it had live frames piling up behind one. Not the high-water mark of the live depth: queue_peak - queue_preroll_peak is a difference of two maxima from possibly different moments, not a maximum of the difference.
  • Attribute queue_capacity — how deep the queue may get before frames are dropped. Derived from the sensor and the frame rate -- about two seconds of frames, capped so a large sensor cannot turn a slow disk into an out-of-memory. Includes the pre-roll a recording was handed at its start, which is why it is not the number to judge a slow drive by.
  • Attribute queue_preroll — how many of the queued frames are the pre-roll this recording was handed at its start, rather than frames the camera delivered while it ran. Zero without a pre-roll, and falls to zero as the handover is written out. 30 s of pre-roll on a 640x480 camera at 32 Hz starts at a depth of 960 against a capacity of 1024 -- 94 % full, on a healthy drive -- which read as the documented early warning is simply wrong.
  • Attribute queue_live_capacity — the room for live frames: queue_capacity less the pre-roll handed over. Constant for the life of a recording and the same quantity whatever the pre-roll was, so "half full" means one thing rather than one thing per pre-roll length.
  • Attribute longest_write_ms — the longest a single frame took to encode and put on disk. On a healthy disk the encode is essentially all of it -- 5.4 ms for a 640x480 frame of 78 KB, measured; a figure in the hundreds of milliseconds is the drive. Nothing waits on this: it is what the recording cost the thread that writes it, not what it cost the camera.
  • Attribute bytes_written_at_us — when bytes_written last changed, in microseconds on the SDK's monotonic clock. This is what makes a write rate exact. The count steps once per Matroska Cluster and both fields move only at those steps, so for two reads a and b::

RecordingStats — properties

frames_lost

Every frame that did not reach the file, however it was lost.

The number worth asserting on after a recording: the three counters behind it have different causes but the same consequence, and a caller that checks only one of them will eventually be surprised by another.

A frame still in the queue is not lost and is not here -- see queue_depth.

RecordingStats — methods

__repr__()