ravi — functions and constants
PIX Connect recordings (.ravi) into SDK recordings (.mkv).
A .ravi is what PIX Connect 3 records. It stores energy counts
and rebuilds temperatures on playback from a header in every frame.
import does that once, with PIX Connect's own model, and writes
an ordinary SDK recording that crate::Camera::from_file plays.
PIX Connect's measuring areas become regions, the recording says
when the original was recorded
(crate::Camera::playback_start_time_us), and it names the camera
model when the file does.
inspect answers "will this convert?" from a few hundred
kilobytes of the file, whatever its size, so a folder of them can be
sorted before anything is converted.
use optris_sdk::ravi::{self, ImportOptions, RaviVerdict};
# fn main() -> optris_sdk::Result<()> {
let info = ravi::inspect("old.ravi", None)?;
if info.verdict == RaviVerdict::Convertible {
let result = ravi::import_with_progress(
"old.ravi",
"old.mkv",
&ImportOptions::new(),
|p| {
eprint!("\rpass {}: {}/{} frames", p.pass, p.frames_done, p.frames_total);
true // false cancels
},
)?;
println!("{} frames, {} regions", result.frames_written, result.regions_created);
}
# Ok(())
# }
The start time and the recording PC's time zone
A .ravi stores when it started as the recording PC's local clock
showed it, with no time zone. Give that PC's zone as a
RaviTimeZone (ImportOptions::time_zone, inspect_in_zone,
inspect_start_time): an IANA name such as "Europe/Berlin"
(daylight saving time follows the zone's rules for the recording's
date) or a fixed offset. Without one, this computer's zone is used and
the recording says it was assumed; correct_start_time sets the
real one afterwards.
Declined is not failed
A file with no radiometric model, or one whose verdict is
RaviVerdict::ShortWave without
ImportOptions::allow_short_wave, is declined: the import
returns an Error whose status is
Status::NotSupported. Every other
failure has another status -- a source that is not a .ravi or a
destination that cannot be written is
Status::Io. inspect says which of the two
declines it is.
pub fn correct_start_time(recording: &str, zone: &RaviTimeZone) -> Result<RaviStartTime>
Set the time zone, and with it the UTC start, of a recording
converted from a .ravi.
For a recording converted without a zone, or with the wrong one. The
start is read again from the recording PC's clock reading the
conversion kept, and every place the recording states its start is
rewritten to match: crate::Camera::playback_start_time_us,
crate::Camera::playback_time_zone (which then says corrected
and no longer assumed) and the documents in the recording. Works
on recordings converted by any SDK release. The recording is written
again beside itself and renamed into place, so it needs free space
for a second copy, and a failure leaves it as it was.
Errors
Status::InvalidArgument when the recording was not converted from
a .ravi (a recording of a camera states the known zone and start of
the computer that made it), for a zone that cannot be used, and for a
recording in several parts; Status::Io when it cannot be read or
rewritten.
pub fn correct_start_time_utc(recording: &str, utc_unix_us: u64) -> Result<RaviStartTime>
Set the UTC start of a recording converted from a .ravi directly,
in microseconds since the Unix epoch, when the instant is known some
other way. The zone becomes the fixed offset between the recording
PC's clock reading and it, to the minute.
Errors
As correct_start_time, and Status::InvalidArgument for a start
more than 18 hours from the clock reading.
pub fn import(source: &str, destination: &str, options: &ImportOptions) -> Result<ImportResult>
Convert a .ravi into an SDK recording at destination.
Temperatures come from PIX Connect's own model, frame by frame, from
each frame's own header. The recording is written beside
destination under a temporary name and moved into place when it
is complete, so a failure leaves nothing at destination, and a
file already there is replaced only by a finished recording.
import_with_progress is the same with progress and cancel.
Errors
- The import declined the file, with
Status::NotSupported: it has no radiometric model, or it is short-wave andImportOptions::allow_short_waveis off. Not a failure;inspectsays which. - The source cannot be read or is not a
.ravi, or the destination cannot be written, withStatus::Io. - A path is empty or contains an interior NUL byte, with
Status::InvalidArgument.
pub fn import_with_progress<F>(
import, reporting progress to progress and stopping when it
returns false.
progress is called after every frame of every pass, on the
calling thread. Returning false cancels: the call then returns
Ok with ImportResult::cancelled set and nothing at the
destination; a file that was already there is untouched.
A panic inside progress cancels the import, which is finished
cleanly in the SDK, and is then resumed on the calling thread once
the SDK has returned, so it is never unwound through C.
Errors
As import.
pub fn inspect(path: &str, norm_directory: Option<&str>) -> Result<RaviInfo>
Say what a .ravi holds and whether it converts.
Reads a few hundred kilobytes whatever the file's size. A missing,
unreadable or foreign file is not an error: it is
RaviVerdict::Unreadable, with the reason in
RaviInfo::detail.
norm_directory is where Norm-<n>.prn is; None uses the tables
the SDK ships. A file whose model is a normalization table needs the
table to be judged convertible.
Errors
Status::InvalidArgument only if
a path contains an interior NUL byte.
pub fn inspect_frame_counts(path: &str) -> Result<RaviFrameCounts>
Say how many frames a .ravi declares, and in which header.
Reads the headers and the RIFF part headers, a few hundred kilobytes
whatever the file's size. A missing, unreadable or foreign file is
not an error: RaviFrameCounts::readable is then false.
Errors
Status::InvalidArgument only if the path contains an interior
NUL byte.
pub fn inspect_in_zone(
inspect, with RaviInfo::recorded_at_utc placed in zone
rather than in this computer's zone (None).
Errors
Status::InvalidArgument for a path or zone name with an interior
NUL byte, and for a zone this computer's zone database does not
have, or an offset past 18 hours.
pub fn inspect_start_time(path: &str, zone: Option<&RaviTimeZone>) -> Result<RaviStartTime>
Say when a .ravi started: the recording PC's clock reading, and that
reading placed in zone, or in this computer's zone for None
(RaviStartTime::time_zone_assumed then says so).
Reads the first frame header only. A file that cannot be read, or
records no start, is not an error: its
RaviStartTime::recorded_at_local is empty.
Errors
Status::InvalidArgument for an interior NUL byte, or a zone that
cannot be used.