mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-07 14:04:10 +03:00
27 lines
777 B
TypeScript
27 lines
777 B
TypeScript
|
|
import { Recording } from "@/types/record";
|
||
|
|
|
||
|
|
/** the HLS endpoint returns the vod segments with the first
|
||
|
|
* segment of the hour trimmed, meaning it will start at
|
||
|
|
* the beginning of the hour, cutting off any difference
|
||
|
|
* that the segment has.
|
||
|
|
*/
|
||
|
|
export function calculateInpointOffset(
|
||
|
|
timeRangeStart: number | undefined,
|
||
|
|
firstRecordingSegment: Recording | undefined,
|
||
|
|
): number {
|
||
|
|
if (!timeRangeStart || !firstRecordingSegment) {
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// if the first recording segment does not cross over
|
||
|
|
// the beginning of the time range then there is no offset
|
||
|
|
if (
|
||
|
|
firstRecordingSegment.start_time < timeRangeStart &&
|
||
|
|
firstRecordingSegment.end_time > timeRangeStart
|
||
|
|
) {
|
||
|
|
return timeRangeStart - firstRecordingSegment.start_time;
|
||
|
|
}
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|