mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-17 02:26:43 +03:00
Compare commits
6 Commits
38a507b6a7
...
2f9a1afab4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f9a1afab4 | ||
|
|
28b0ad782a | ||
|
|
513bede475 | ||
|
|
7d5317959d | ||
|
|
f85a1fe3e8 | ||
|
|
4d0456dcf0 |
@ -837,7 +837,19 @@ async def recording_clip(
|
|||||||
dependencies=[Depends(require_camera_access)],
|
dependencies=[Depends(require_camera_access)],
|
||||||
description="Returns an HLS playlist for the specified timestamp-range on the specified camera. Append /master.m3u8 or /index.m3u8 for HLS playback.",
|
description="Returns an HLS playlist for the specified timestamp-range on the specified camera. Append /master.m3u8 or /index.m3u8 for HLS playback.",
|
||||||
)
|
)
|
||||||
async def vod_ts(camera_name: str, start_ts: float, end_ts: float):
|
async def vod_ts(
|
||||||
|
camera_name: str,
|
||||||
|
start_ts: float,
|
||||||
|
end_ts: float,
|
||||||
|
force_discontinuity: bool = False,
|
||||||
|
):
|
||||||
|
logger.debug(
|
||||||
|
"VOD: Generating VOD for %s from %s to %s with force_discontinuity=%s",
|
||||||
|
camera_name,
|
||||||
|
start_ts,
|
||||||
|
end_ts,
|
||||||
|
force_discontinuity,
|
||||||
|
)
|
||||||
recordings = (
|
recordings = (
|
||||||
Recordings.select(
|
Recordings.select(
|
||||||
Recordings.path,
|
Recordings.path,
|
||||||
@ -862,6 +874,14 @@ async def vod_ts(camera_name: str, start_ts: float, end_ts: float):
|
|||||||
|
|
||||||
recording: Recordings
|
recording: Recordings
|
||||||
for recording in recordings:
|
for recording in recordings:
|
||||||
|
logger.debug(
|
||||||
|
"VOD: processing recording: %s start=%s end=%s duration=%s",
|
||||||
|
recording.path,
|
||||||
|
recording.start_time,
|
||||||
|
recording.end_time,
|
||||||
|
recording.duration,
|
||||||
|
)
|
||||||
|
|
||||||
clip = {"type": "source", "path": recording.path}
|
clip = {"type": "source", "path": recording.path}
|
||||||
duration = int(recording.duration * 1000)
|
duration = int(recording.duration * 1000)
|
||||||
|
|
||||||
@ -870,6 +890,11 @@ async def vod_ts(camera_name: str, start_ts: float, end_ts: float):
|
|||||||
inpoint = int((start_ts - recording.start_time) * 1000)
|
inpoint = int((start_ts - recording.start_time) * 1000)
|
||||||
clip["clipFrom"] = inpoint
|
clip["clipFrom"] = inpoint
|
||||||
duration -= inpoint
|
duration -= inpoint
|
||||||
|
logger.debug(
|
||||||
|
"VOD: applied clipFrom %sms to %s",
|
||||||
|
inpoint,
|
||||||
|
recording.path,
|
||||||
|
)
|
||||||
|
|
||||||
# adjust end if recording.end_time is after end_ts
|
# adjust end if recording.end_time is after end_ts
|
||||||
if recording.end_time > end_ts:
|
if recording.end_time > end_ts:
|
||||||
@ -877,12 +902,23 @@ async def vod_ts(camera_name: str, start_ts: float, end_ts: float):
|
|||||||
|
|
||||||
if duration < min_duration_ms:
|
if duration < min_duration_ms:
|
||||||
# skip if the clip has no valid duration (too short to contain frames)
|
# skip if the clip has no valid duration (too short to contain frames)
|
||||||
|
logger.debug(
|
||||||
|
"VOD: skipping recording %s - resulting duration %sms too short",
|
||||||
|
recording.path,
|
||||||
|
duration,
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if min_duration_ms <= duration < max_duration_ms:
|
if min_duration_ms <= duration < max_duration_ms:
|
||||||
clip["keyFrameDurations"] = [duration]
|
clip["keyFrameDurations"] = [duration]
|
||||||
clips.append(clip)
|
clips.append(clip)
|
||||||
durations.append(duration)
|
durations.append(duration)
|
||||||
|
logger.debug(
|
||||||
|
"VOD: added clip %s duration_ms=%s clipFrom=%s",
|
||||||
|
recording.path,
|
||||||
|
duration,
|
||||||
|
clip.get("clipFrom"),
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
logger.warning(f"Recording clip is missing or empty: {recording.path}")
|
logger.warning(f"Recording clip is missing or empty: {recording.path}")
|
||||||
|
|
||||||
@ -902,7 +938,7 @@ async def vod_ts(camera_name: str, start_ts: float, end_ts: float):
|
|||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content={
|
content={
|
||||||
"cache": hour_ago.timestamp() > start_ts,
|
"cache": hour_ago.timestamp() > start_ts,
|
||||||
"discontinuity": False,
|
"discontinuity": force_discontinuity,
|
||||||
"consistentSequenceMediaInfo": True,
|
"consistentSequenceMediaInfo": True,
|
||||||
"durations": durations,
|
"durations": durations,
|
||||||
"segment_duration": max(durations),
|
"segment_duration": max(durations),
|
||||||
@ -986,6 +1022,19 @@ async def vod_event(
|
|||||||
return vod_response
|
return vod_response
|
||||||
|
|
||||||
|
|
||||||
|
@router.get(
|
||||||
|
"/vod/clip/{camera_name}/start/{start_ts}/end/{end_ts}",
|
||||||
|
dependencies=[Depends(require_camera_access)],
|
||||||
|
description="Returns an HLS playlist for a timestamp range with HLS discontinuity enabled. Append /master.m3u8 or /index.m3u8 for HLS playback.",
|
||||||
|
)
|
||||||
|
async def vod_clip(
|
||||||
|
camera_name: str,
|
||||||
|
start_ts: float,
|
||||||
|
end_ts: float,
|
||||||
|
):
|
||||||
|
return await vod_ts(camera_name, start_ts, end_ts, force_discontinuity=True)
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
"/events/{event_id}/snapshot.jpg",
|
"/events/{event_id}/snapshot.jpg",
|
||||||
description="Returns a snapshot image for the specified object id. NOTE: The query params only take affect while the event is in-progress. Once the event has ended the snapshot configuration is used.",
|
description="Returns a snapshot image for the specified object id. NOTE: The query params only take affect while the event is in-progress. Once the event has ended the snapshot configuration is used.",
|
||||||
|
|||||||
@ -22,6 +22,7 @@ from frigate.util.services import (
|
|||||||
get_bandwidth_stats,
|
get_bandwidth_stats,
|
||||||
get_cpu_stats,
|
get_cpu_stats,
|
||||||
get_fs_type,
|
get_fs_type,
|
||||||
|
get_hailo_temps,
|
||||||
get_intel_gpu_stats,
|
get_intel_gpu_stats,
|
||||||
get_jetson_stats,
|
get_jetson_stats,
|
||||||
get_nvidia_gpu_stats,
|
get_nvidia_gpu_stats,
|
||||||
@ -91,6 +92,9 @@ def get_temperatures() -> dict[str, float]:
|
|||||||
if temp is not None:
|
if temp is not None:
|
||||||
temps[apex] = temp
|
temps[apex] = temp
|
||||||
|
|
||||||
|
# Get temperatures for Hailo devices
|
||||||
|
temps.update(get_hailo_temps())
|
||||||
|
|
||||||
return temps
|
return temps
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -549,6 +549,53 @@ def get_jetson_stats() -> Optional[dict[int, dict]]:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def get_hailo_temps() -> dict[str, float]:
|
||||||
|
"""Get temperatures for Hailo devices."""
|
||||||
|
try:
|
||||||
|
from hailo_platform import Device
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
temps = {}
|
||||||
|
|
||||||
|
try:
|
||||||
|
device_ids = Device.scan()
|
||||||
|
for i, device_id in enumerate(device_ids):
|
||||||
|
try:
|
||||||
|
with Device(device_id) as device:
|
||||||
|
temp_info = device.control.get_chip_temperature()
|
||||||
|
|
||||||
|
# Get board name and normalise it
|
||||||
|
identity = device.control.identify()
|
||||||
|
board_name = None
|
||||||
|
for line in str(identity).split("\n"):
|
||||||
|
if line.startswith("Board Name:"):
|
||||||
|
board_name = (
|
||||||
|
line.split(":", 1)[1].strip().lower().replace("-", "")
|
||||||
|
)
|
||||||
|
break
|
||||||
|
|
||||||
|
if not board_name:
|
||||||
|
board_name = f"hailo{i}"
|
||||||
|
|
||||||
|
# Use indexed name if multiple devices, otherwise just the board name
|
||||||
|
device_name = (
|
||||||
|
f"{board_name}-{i}" if len(device_ids) > 1 else board_name
|
||||||
|
)
|
||||||
|
|
||||||
|
# ts1_temperature is also available, but appeared to be the same as ts0 in testing.
|
||||||
|
temps[device_name] = round(temp_info.ts0_temperature, 1)
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug(
|
||||||
|
f"Failed to get temperature for Hailo device {device_id}: {e}"
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug(f"Failed to scan for Hailo devices: {e}")
|
||||||
|
|
||||||
|
return temps
|
||||||
|
|
||||||
|
|
||||||
def ffprobe_stream(ffmpeg, path: str, detailed: bool = False) -> sp.CompletedProcess:
|
def ffprobe_stream(ffmpeg, path: str, detailed: bool = False) -> sp.CompletedProcess:
|
||||||
"""Run ffprobe on stream."""
|
"""Run ffprobe on stream."""
|
||||||
clean_path = escape_special_characters(path)
|
clean_path = escape_special_characters(path)
|
||||||
|
|||||||
@ -446,7 +446,7 @@ export function TrackingDetails({
|
|||||||
(event.end_time ?? Date.now() / 1000) + annotationOffset / 1000;
|
(event.end_time ?? Date.now() / 1000) + annotationOffset / 1000;
|
||||||
const startTime = eventStartRecord - REVIEW_PADDING;
|
const startTime = eventStartRecord - REVIEW_PADDING;
|
||||||
const endTime = eventEndRecord + REVIEW_PADDING;
|
const endTime = eventEndRecord + REVIEW_PADDING;
|
||||||
const playlist = `${baseUrl}vod/${event.camera}/start/${startTime}/end/${endTime}/index.m3u8`;
|
const playlist = `${baseUrl}vod/clip/${event.camera}/start/${startTime}/end/${endTime}/index.m3u8`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
playlist,
|
playlist,
|
||||||
@ -559,7 +559,6 @@ export function TrackingDetails({
|
|||||||
isDetailMode={true}
|
isDetailMode={true}
|
||||||
camera={event.camera}
|
camera={event.camera}
|
||||||
currentTimeOverride={currentTime}
|
currentTimeOverride={currentTime}
|
||||||
enableGapControllerRecovery={true}
|
|
||||||
/>
|
/>
|
||||||
{isVideoLoading && (
|
{isVideoLoading && (
|
||||||
<ActivityIndicator className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2" />
|
<ActivityIndicator className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2" />
|
||||||
|
|||||||
@ -57,7 +57,6 @@ type HlsVideoPlayerProps = {
|
|||||||
isDetailMode?: boolean;
|
isDetailMode?: boolean;
|
||||||
camera?: string;
|
camera?: string;
|
||||||
currentTimeOverride?: number;
|
currentTimeOverride?: number;
|
||||||
enableGapControllerRecovery?: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function HlsVideoPlayer({
|
export default function HlsVideoPlayer({
|
||||||
@ -82,7 +81,6 @@ export default function HlsVideoPlayer({
|
|||||||
isDetailMode = false,
|
isDetailMode = false,
|
||||||
camera,
|
camera,
|
||||||
currentTimeOverride,
|
currentTimeOverride,
|
||||||
enableGapControllerRecovery = false,
|
|
||||||
}: HlsVideoPlayerProps) {
|
}: HlsVideoPlayerProps) {
|
||||||
const { t } = useTranslation("components/player");
|
const { t } = useTranslation("components/player");
|
||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
@ -173,21 +171,12 @@ export default function HlsVideoPlayer({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Base HLS configuration
|
// Base HLS configuration
|
||||||
const baseConfig: Partial<HlsConfig> = {
|
const hlsConfig: Partial<HlsConfig> = {
|
||||||
maxBufferLength: 10,
|
maxBufferLength: 10,
|
||||||
maxBufferSize: 20 * 1000 * 1000,
|
maxBufferSize: 20 * 1000 * 1000,
|
||||||
startPosition: currentSource.startPosition,
|
startPosition: currentSource.startPosition,
|
||||||
};
|
};
|
||||||
|
|
||||||
const hlsConfig = { ...baseConfig };
|
|
||||||
|
|
||||||
if (enableGapControllerRecovery) {
|
|
||||||
hlsConfig.highBufferWatchdogPeriod = 1; // Check for stalls every 1 second (default: 3)
|
|
||||||
hlsConfig.nudgeOffset = 0.2; // Nudge playhead forward 0.2s when stalled (default: 0.1)
|
|
||||||
hlsConfig.nudgeMaxRetry = 5; // Try up to 5 nudges before giving up (default: 3)
|
|
||||||
hlsConfig.maxBufferHole = 0.5; // Tolerate up to 0.5s gaps between fragments (default: 0.1)
|
|
||||||
}
|
|
||||||
|
|
||||||
hlsRef.current = new Hls(hlsConfig);
|
hlsRef.current = new Hls(hlsConfig);
|
||||||
hlsRef.current.attachMedia(videoRef.current);
|
hlsRef.current.attachMedia(videoRef.current);
|
||||||
hlsRef.current.loadSource(currentSource.playlist);
|
hlsRef.current.loadSource(currentSource.playlist);
|
||||||
@ -201,13 +190,7 @@ export default function HlsVideoPlayer({
|
|||||||
hlsRef.current.destroy();
|
hlsRef.current.destroy();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, [
|
}, [videoRef, hlsRef, useHlsCompat, currentSource]);
|
||||||
videoRef,
|
|
||||||
hlsRef,
|
|
||||||
useHlsCompat,
|
|
||||||
currentSource,
|
|
||||||
enableGapControllerRecovery,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// state handling
|
// state handling
|
||||||
|
|
||||||
|
|||||||
@ -144,7 +144,7 @@ export default function GeneralMetrics({
|
|||||||
}
|
}
|
||||||
|
|
||||||
Object.entries(stats.detectors).forEach(([key], cIdx) => {
|
Object.entries(stats.detectors).forEach(([key], cIdx) => {
|
||||||
if (!key.includes("coral")) {
|
if (!key.includes("coral") && !key.includes("hailo")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user