optris::sdk::rec::FrameIndex
Every frame of one recording, built once and then only read.
Thread safety: Thread safety Immutable after Build(). Any number of threads may read one.
Public static functions
Build
static auto Build(const std::string &path) -> FrameIndex
Index a recording without decoding it.
Parameters
| Name | Description |
|---|---|
path |
Path to a .mkv written by this SDK, or any container FFmpeg can demux. |
Returns: The index. A file with a video stream and no frames in it indexes successfully and is Empty(); that is a real state (a take that was stopped before its first frame) and not an error.
Exceptions
| Name | Description |
|---|---|
IoException |
if the file cannot be opened or is not a container FFmpeg understands. |
SdkException |
if the file carries no video stream, or on an allocation failure. |
Public functions
Count
auto Count() const -> size_t
How many frames the recording holds.
Counted from the container, so this is exact. It is not GetDurationUs() * GetFrameRate(), which is an estimate over a declared rate and is wrong whenever the camera did not deliver at the rate the header claims.
Empty
auto Empty() const -> bool
Whether the recording holds no frames at all.
A real state rather than an error: a take stopped before its first frame arrived indexes successfully and is empty. Callers that go straight to At(0) get nothing and should check this first, because "no frames" and "frame 0 is unreachable" want different messages.
Entries
auto Entries() const -> const std::vector< FrameIndexEntry > &
Every entry, in container order.
At
auto At(uint64_t frame) const -> std::optional< FrameIndexEntry >
One frame's entry, or nothing when frame is past the end.
AnchorFor
auto AnchorFor(uint64_t frame) const -> uint64_t
The nearest frame at or before frame that a decoder can start from.
Never greater than frame, so decoding forward from the result always reaches it. Returns 0 for an empty index and for a frame past the end; there is nothing to seek to in either case, and a caller that checks At() first will not ask.
The first frame of a recording is treated as an anchor whether or not it is flagged as one, because a decoder starting at the beginning of the file has nothing before it to be missing.
AnchorCount
auto AnchorCount() const -> size_t
How many frames are seek anchors.
Equal to Count() for an all-intra recording. Far below it for anything this SDK writes today.
FrameAt
auto FrameAt(uint64_t timestamp_us) const -> uint64_t
The frame shown at timestamp_us.
The last frame whose presentation time is at or before the timestamp, which is the frame a viewer would be looking at. Clamped to the last frame for a timestamp past the end, and 0 for an empty index.
DurationUs
auto DurationUs() const -> uint64_t
Presentation time of the last frame, in microseconds.
Zero for an empty index. This is the time of the last frame's start, not the end of its interval, so it is slightly shorter than Player::GetDurationUs(); a timeline that maps a scrub position onto a frame wants this one.