mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-09 15:05:26 +03:00
Compare commits
No commits in common. "1188d87588d5e9aef35c4311c70e08542942edf7" and "41e290449e9efb35d250cf67c38eeffe201b3331" have entirely different histories.
1188d87588
...
41e290449e
@ -55,7 +55,7 @@ function setup_homekit_config() {
|
|||||||
|
|
||||||
if [[ ! -f "${config_path}" ]]; then
|
if [[ ! -f "${config_path}" ]]; then
|
||||||
echo "[INFO] Creating empty config file for HomeKit..."
|
echo "[INFO] Creating empty config file for HomeKit..."
|
||||||
: > "${config_path}"
|
echo '{}' > "${config_path}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Convert YAML to JSON for jq processing
|
# Convert YAML to JSON for jq processing
|
||||||
@ -65,25 +65,23 @@ function setup_homekit_config() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use jq to extract the homekit section, if it exists
|
# Use jq to filter and keep only the homekit section
|
||||||
local homekit_json
|
local cleaned_json="/tmp/cache/homekit_cleaned.json"
|
||||||
homekit_json=$(jq '
|
jq '
|
||||||
if has("homekit") then {homekit: .homekit} else null end
|
# Keep only the homekit section if it exists, otherwise empty object
|
||||||
' "${temp_json}" 2>/dev/null) || homekit_json="null"
|
if has("homekit") then {homekit: .homekit} else {} end
|
||||||
|
' "${temp_json}" > "${cleaned_json}" 2>/dev/null || {
|
||||||
|
echo '{}' > "${cleaned_json}"
|
||||||
|
}
|
||||||
|
|
||||||
# If no homekit section, write an empty config file
|
# Convert back to YAML and write to the config file
|
||||||
if [[ "${homekit_json}" == "null" ]]; then
|
yq eval -P "${cleaned_json}" > "${config_path}" 2>/dev/null || {
|
||||||
: > "${config_path}"
|
echo "[WARNING] Failed to convert cleaned config to YAML, creating minimal config"
|
||||||
else
|
echo '{}' > "${config_path}"
|
||||||
# Convert homekit JSON back to YAML and write to the config file
|
}
|
||||||
echo "${homekit_json}" | yq eval -P - > "${config_path}" 2>/dev/null || {
|
|
||||||
echo "[WARNING] Failed to convert cleaned config to YAML, creating minimal config"
|
|
||||||
: > "${config_path}"
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Clean up temp files
|
# Clean up temp files
|
||||||
rm -f "${temp_json}"
|
rm -f "${temp_json}" "${cleaned_json}"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_libva_version
|
set_libva_version
|
||||||
|
|||||||
@ -20,10 +20,7 @@ import type {
|
|||||||
CameraConfigData,
|
CameraConfigData,
|
||||||
ConfigSetBody,
|
ConfigSetBody,
|
||||||
} from "@/types/cameraWizard";
|
} from "@/types/cameraWizard";
|
||||||
import {
|
import { processCameraName } from "@/utils/cameraUtil";
|
||||||
processCameraName,
|
|
||||||
calculateDetectDimensions,
|
|
||||||
} from "@/utils/cameraUtil";
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
type WizardState = {
|
type WizardState = {
|
||||||
@ -206,25 +203,6 @@ export default function CameraWizardDialog({
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Calculate detect dimensions from the detect stream's probed resolution
|
|
||||||
const detectStream = wizardData.streams.find((stream) =>
|
|
||||||
stream.roles.includes("detect"),
|
|
||||||
);
|
|
||||||
if (detectStream?.testResult?.resolution) {
|
|
||||||
const [streamWidth, streamHeight] = detectStream.testResult.resolution
|
|
||||||
.split("x")
|
|
||||||
.map(Number);
|
|
||||||
if (streamWidth > 0 && streamHeight > 0) {
|
|
||||||
const detectDimensions = calculateDetectDimensions(
|
|
||||||
streamWidth,
|
|
||||||
streamHeight,
|
|
||||||
);
|
|
||||||
if (detectDimensions) {
|
|
||||||
configData.cameras[finalCameraName].detect = detectDimensions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add live.streams configuration for go2rtc streams
|
// Add live.streams configuration for go2rtc streams
|
||||||
if (wizardData.streams && wizardData.streams.length > 0) {
|
if (wizardData.streams && wizardData.streams.length > 0) {
|
||||||
configData.cameras[finalCameraName].live = {
|
configData.cameras[finalCameraName].live = {
|
||||||
|
|||||||
@ -162,10 +162,6 @@ export type CameraConfigData = {
|
|||||||
input_args?: string;
|
input_args?: string;
|
||||||
}[];
|
}[];
|
||||||
};
|
};
|
||||||
detect?: {
|
|
||||||
width: number;
|
|
||||||
height: number;
|
|
||||||
};
|
|
||||||
live?: {
|
live?: {
|
||||||
streams: Record<string, string>;
|
streams: Record<string, string>;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -115,51 +115,6 @@ export type CameraAudioFeatures = {
|
|||||||
* @param requireSecureContext - If true, two-way audio requires secure context (default: true)
|
* @param requireSecureContext - If true, two-way audio requires secure context (default: true)
|
||||||
* @returns CameraAudioFeatures object with detected capabilities
|
* @returns CameraAudioFeatures object with detected capabilities
|
||||||
*/
|
*/
|
||||||
/**
|
|
||||||
* Calculates optimal detect dimensions from stream resolution.
|
|
||||||
*
|
|
||||||
* Scales dimensions to an efficient size for object detection while
|
|
||||||
* preserving the stream's aspect ratio. Does not upscale.
|
|
||||||
*
|
|
||||||
* @param streamWidth - Native stream width in pixels
|
|
||||||
* @param streamHeight - Native stream height in pixels
|
|
||||||
* @returns Detect dimensions with even values, or null if inputs are invalid
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Target size for the smaller dimension (width or height) for detect streams
|
|
||||||
export const DETECT_TARGET_PX = 720;
|
|
||||||
|
|
||||||
export function calculateDetectDimensions(
|
|
||||||
streamWidth: number,
|
|
||||||
streamHeight: number,
|
|
||||||
): { width: number; height: number } | null {
|
|
||||||
if (
|
|
||||||
!Number.isFinite(streamWidth) ||
|
|
||||||
!Number.isFinite(streamHeight) ||
|
|
||||||
streamWidth <= 0 ||
|
|
||||||
streamHeight <= 0
|
|
||||||
) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const smallerDim = Math.min(streamWidth, streamHeight);
|
|
||||||
const target = Math.min(DETECT_TARGET_PX, smallerDim);
|
|
||||||
const scale = target / smallerDim;
|
|
||||||
|
|
||||||
let width = Math.round(streamWidth * scale);
|
|
||||||
let height = Math.round(streamHeight * scale);
|
|
||||||
|
|
||||||
// Round down to even numbers (required for video processing)
|
|
||||||
width = width - (width % 2);
|
|
||||||
height = height - (height % 2);
|
|
||||||
|
|
||||||
if (width < 2 || height < 2) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return { width, height };
|
|
||||||
}
|
|
||||||
|
|
||||||
export function detectCameraAudioFeatures(
|
export function detectCameraAudioFeatures(
|
||||||
metadata: LiveStreamMetadata | null | undefined,
|
metadata: LiveStreamMetadata | null | undefined,
|
||||||
requireSecureContext: boolean = true,
|
requireSecureContext: boolean = true,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user