mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-08-04 13:47:37 +02:00
Misc fixes (#18289)
* Fix key not moved * Account for HLS start offset when seeking and calculating update time
This commit is contained in:
parent
f4d5ebf4db
commit
717517aeb5
@ -37,6 +37,7 @@ type HlsVideoPlayerProps = {
|
|||||||
supportsFullscreen: boolean;
|
supportsFullscreen: boolean;
|
||||||
fullscreen: boolean;
|
fullscreen: boolean;
|
||||||
frigateControls?: boolean;
|
frigateControls?: boolean;
|
||||||
|
inpointOffset?: number;
|
||||||
onClipEnded?: () => void;
|
onClipEnded?: () => void;
|
||||||
onPlayerLoaded?: () => void;
|
onPlayerLoaded?: () => void;
|
||||||
onTimeUpdate?: (time: number) => void;
|
onTimeUpdate?: (time: number) => void;
|
||||||
@ -55,6 +56,7 @@ export default function HlsVideoPlayer({
|
|||||||
supportsFullscreen,
|
supportsFullscreen,
|
||||||
fullscreen,
|
fullscreen,
|
||||||
frigateControls = true,
|
frigateControls = true,
|
||||||
|
inpointOffset = 0,
|
||||||
onClipEnded,
|
onClipEnded,
|
||||||
onPlayerLoaded,
|
onPlayerLoaded,
|
||||||
onTimeUpdate,
|
onTimeUpdate,
|
||||||
@ -187,6 +189,16 @@ export default function HlsVideoPlayer({
|
|||||||
};
|
};
|
||||||
}, [videoRef, controlsOpen]);
|
}, [videoRef, controlsOpen]);
|
||||||
|
|
||||||
|
const getVideoTime = useCallback(() => {
|
||||||
|
const currentTime = videoRef.current?.currentTime;
|
||||||
|
|
||||||
|
if (!currentTime) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentTime + inpointOffset;
|
||||||
|
}, [videoRef, inpointOffset]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TransformWrapper
|
<TransformWrapper
|
||||||
minScale={1.0}
|
minScale={1.0}
|
||||||
@ -218,7 +230,7 @@ export default function HlsVideoPlayer({
|
|||||||
hotKeys={hotKeys}
|
hotKeys={hotKeys}
|
||||||
onPlayPause={onPlayPause}
|
onPlayPause={onPlayPause}
|
||||||
onSeek={(diff) => {
|
onSeek={(diff) => {
|
||||||
const currentTime = videoRef.current?.currentTime;
|
const currentTime = getVideoTime();
|
||||||
|
|
||||||
if (!videoRef.current || !currentTime) {
|
if (!videoRef.current || !currentTime) {
|
||||||
return;
|
return;
|
||||||
@ -234,8 +246,10 @@ export default function HlsVideoPlayer({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onUploadFrame={async () => {
|
onUploadFrame={async () => {
|
||||||
if (videoRef.current && onUploadFrame) {
|
const frameTime = getVideoTime();
|
||||||
const resp = await onUploadFrame(videoRef.current.currentTime);
|
|
||||||
|
if (frameTime && onUploadFrame) {
|
||||||
|
const resp = await onUploadFrame(frameTime);
|
||||||
|
|
||||||
if (resp && resp.status == 200) {
|
if (resp && resp.status == 200) {
|
||||||
toast.success(t("toast.success.submittedFrigatePlus"), {
|
toast.success(t("toast.success.submittedFrigatePlus"), {
|
||||||
@ -335,11 +349,17 @@ export default function HlsVideoPlayer({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onTimeUpdate={() =>
|
onTimeUpdate={() => {
|
||||||
onTimeUpdate && videoRef.current
|
if (!onTimeUpdate) {
|
||||||
? onTimeUpdate(videoRef.current.currentTime)
|
return;
|
||||||
: undefined
|
}
|
||||||
}
|
|
||||||
|
const frameTime = getVideoTime();
|
||||||
|
|
||||||
|
if (frameTime) {
|
||||||
|
onTimeUpdate(frameTime);
|
||||||
|
}
|
||||||
|
}}
|
||||||
onLoadedData={() => {
|
onLoadedData={() => {
|
||||||
onPlayerLoaded?.();
|
onPlayerLoaded?.();
|
||||||
handleLoadedMetadata();
|
handleLoadedMetadata();
|
||||||
|
@ -17,6 +17,7 @@ export class DynamicVideoController {
|
|||||||
// playback
|
// playback
|
||||||
private recordings: Recording[] = [];
|
private recordings: Recording[] = [];
|
||||||
private timeRange: TimeRange = { after: 0, before: 0 };
|
private timeRange: TimeRange = { after: 0, before: 0 };
|
||||||
|
private inpointOffset: number = 0;
|
||||||
private annotationOffset: number;
|
private annotationOffset: number;
|
||||||
private timeToStart: number | undefined = undefined;
|
private timeToStart: number | undefined = undefined;
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ export class DynamicVideoController {
|
|||||||
newPlayback(newPlayback: DynamicPlayback) {
|
newPlayback(newPlayback: DynamicPlayback) {
|
||||||
this.recordings = newPlayback.recordings;
|
this.recordings = newPlayback.recordings;
|
||||||
this.timeRange = newPlayback.timeRange;
|
this.timeRange = newPlayback.timeRange;
|
||||||
|
this.inpointOffset = this.timeRange.after - this.recordings[0].start_time;
|
||||||
|
|
||||||
if (this.timeToStart) {
|
if (this.timeToStart) {
|
||||||
this.seekToTimestamp(this.timeToStart);
|
this.seekToTimestamp(this.timeToStart);
|
||||||
@ -92,6 +94,9 @@ export class DynamicVideoController {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// adjust for HLS inpoint offset
|
||||||
|
seekSeconds -= this.inpointOffset;
|
||||||
|
|
||||||
if (seekSeconds != 0) {
|
if (seekSeconds != 0) {
|
||||||
this.playerController.currentTime = seekSeconds;
|
this.playerController.currentTime = seekSeconds;
|
||||||
|
|
||||||
|
@ -197,6 +197,19 @@ export default function DynamicVideoPlayer({
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [controller, recordings]);
|
}, [controller, recordings]);
|
||||||
|
|
||||||
|
/** 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.
|
||||||
|
*/
|
||||||
|
const inpointOffset = useMemo(() => {
|
||||||
|
if (!recordingParams || !recordings) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return recordingParams.after - recordings[0].start_time;
|
||||||
|
}, [recordingParams, recordings]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<HlsVideoPlayer
|
<HlsVideoPlayer
|
||||||
@ -207,6 +220,7 @@ export default function DynamicVideoPlayer({
|
|||||||
hotKeys={hotKeys}
|
hotKeys={hotKeys}
|
||||||
supportsFullscreen={supportsFullscreen}
|
supportsFullscreen={supportsFullscreen}
|
||||||
fullscreen={fullscreen}
|
fullscreen={fullscreen}
|
||||||
|
inpointOffset={inpointOffset}
|
||||||
onTimeUpdate={onTimeUpdate}
|
onTimeUpdate={onTimeUpdate}
|
||||||
onPlayerLoaded={onPlayerLoaded}
|
onPlayerLoaded={onPlayerLoaded}
|
||||||
onClipEnded={onClipEnded}
|
onClipEnded={onClipEnded}
|
||||||
|
@ -675,10 +675,9 @@ export function RecordingView({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip>
|
<Tooltip key={cam}>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<div
|
<div
|
||||||
key={cam}
|
|
||||||
className={
|
className={
|
||||||
mainCameraAspect == "tall" ? "w-full" : "h-full"
|
mainCameraAspect == "tall" ? "w-full" : "h-full"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user