recording — functions
Recording what a camera sees, and replaying it.
Until now this binding could write a still image and read one back --
optris_sdk.snapshot -- and nothing else. The recorder, the
pre-roll buffer, the time-lapse writer and the whole of playback had no
route through this package, although every one of them has been in the
flat C ABI since ABI 12. So a Python caller could describe a single
moment and not a span of time, and #7 could not list a Python
record_and_replay example because there was nothing to write it
against.
The five things this module adds
Recording writes frames to an .mkv as they arrive. Start it
with optris_sdk.camera.Camera.start_recording, or -- better --
with optris_sdk.camera.Camera.recording, which is a context
manager and stops the recording even when the body raises.
Pre-roll keeps the last few seconds in memory so the file can begin before the moment you decided to record. Without it, a recording started by an event always misses the event.
Interval capture writes a still every so often, for a time-lapse or an unattended run. It is independent of recording: stopping one does not stop the other.
Playback reopens a recording as a
optris_sdk.camera.Camera through
optris_sdk.camera.Camera.open_recording. Frames, regions,
alarms and palettes all work on it unchanged; what only real hardware
can do -- the shutter, the focus motor, the recorder itself -- raises
optris_sdk.errors.NotSupportedError rather than quietly doing
nothing.
A finished recording is a RecordingFile: open an .mkv
with no camera and no playback and read the files it carries, or add a
file to one that has already been written. Until this existed a Python
caller could write a recording and could not ask what was in it --
seven C entry points that .NET had and this binding did not, which is
the sharpest single instance of the gap Karl heard reported. The whole
recording family is now reachable from Python.
Seconds, not milliseconds
The ABI spells recording durations in milliseconds and playback
positions in microseconds. Neither appears here: every duration on this
surface is seconds, as a float, matching connect_timeout_s and
flag_interval_s elsewhere in the package. The conversion happens at
the boundary, once, so that no caller has to remember which of the two
units a particular call wanted.
A recording can still fail after it has started
A path that cannot be written fails at
optris_sdk.camera.Camera.start_recording: the call opens the
container, so a directory that does not exist, a permission that
forbids writing or a stick that is not mounted raises there, while
there is still a caller to raise at, and
optris_sdk.camera.Camera.is_recording stays False. This
docstring used to say the opposite -- that the file was not opened
during the call, so an unwritable path reported success and
is_recording then agreed while nothing was written. That was true
until the SDK began opening the output during the call.
What is still silent is a failure after a successful start: a disk
that fills, a drive pulled mid-recording, or a write refused part way
through. That happens on the recording thread, long after
start_recording returned, where there is no caller to raise at.
There are two honest answers and this package offers both. Register
optris_sdk.camera.Camera.on_recording and you are told when a
recording fails, or read
optris_sdk.camera.Camera.recording_stats afterwards, which
counts the frames that never reached the file and keeps the last error
string. RecordingStats.frames_lost is the one number worth
asserting on.
recording_phase_name(phase)
What happened to a recording, spelled out rather than as an ordinal.
recording_stop_reason_name(reason)
Who ended a recording, spelled out rather than as an ordinal.
read_attachments(path)
Every file carried inside a recording or a snapshot.
One call for the case where the path came from a folder listing and
its kind is not known in advance -- a convenience over
RecordingFile and
optris_sdk.snapshot.Snapshot. Prefer the typed opens when
the kind is known: they answer more than the attachments, and they
do not have to guess from an extension.
The extension decides which reader is used, because the two
containers have nothing in common but what they carry. .mkv is
a recording; .png, .tif and .tiff are snapshots. A
.csv snapshot is write-only and carries nothing to read back,
so it raises rather than returning an empty list.
Returns a list of optris_sdk.snapshot.Attachment with
their bytes already read, so the result outlives the file handle.