mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-04-24 01:16:47 +02:00
Onvif: skip non-video profiles in setup (#9708)
* use first h264 onvif profile * error if profile remains unset * move create_ptz_service call * add profile logger debug
This commit is contained in:
parent
86341c3172
commit
dc2e8f7f70
@ -67,22 +67,56 @@ class OnvifController:
|
|||||||
|
|
||||||
# create init services
|
# create init services
|
||||||
media = onvif.create_media_service()
|
media = onvif.create_media_service()
|
||||||
|
logger.debug(f"Onvif media xaddr for {camera_name}: {media.xaddr}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# this will fire an exception if camera is not a ptz
|
# this will fire an exception if camera is not a ptz
|
||||||
capabilities = onvif.get_definition("ptz")
|
capabilities = onvif.get_definition("ptz")
|
||||||
logger.debug(f"Onvif capabilities for {camera_name}: {capabilities}")
|
logger.debug(f"Onvif capabilities for {camera_name}: {capabilities}")
|
||||||
profile = media.GetProfiles()[0]
|
|
||||||
except (ONVIFError, Fault, TransportError) as e:
|
except (ONVIFError, Fault, TransportError) as e:
|
||||||
logger.error(f"Unable to connect to camera: {camera_name}: {e}")
|
logger.error(
|
||||||
|
f"Unable to get Onvif capabilities for camera: {camera_name}: {e}"
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
|
try:
|
||||||
|
profiles = media.GetProfiles()
|
||||||
|
except (ONVIFError, Fault, TransportError) as e:
|
||||||
|
logger.error(
|
||||||
|
f"Unable to get Onvif media profiles for camera: {camera_name}: {e}"
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
|
profile = None
|
||||||
|
for key, onvif_profile in enumerate(profiles):
|
||||||
|
if (
|
||||||
|
onvif_profile.VideoEncoderConfiguration
|
||||||
|
and onvif_profile.VideoEncoderConfiguration.Encoding == "H264"
|
||||||
|
):
|
||||||
|
profile = onvif_profile
|
||||||
|
logger.debug(f"Selected Onvif profile for {camera_name}: {profile}")
|
||||||
|
break
|
||||||
|
|
||||||
|
if profile is None:
|
||||||
|
logger.error(
|
||||||
|
f"No appropriate Onvif profiles found for camera: {camera_name}."
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
|
# get the PTZ config for the profile
|
||||||
|
try:
|
||||||
|
configs = profile.PTZConfiguration
|
||||||
|
logger.debug(
|
||||||
|
f"Onvif ptz config for media profile in {camera_name}: {configs}"
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(
|
||||||
|
f"Invalid Onvif PTZ configuration for camera: {camera_name}: {e}"
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
ptz = onvif.create_ptz_service()
|
ptz = onvif.create_ptz_service()
|
||||||
|
|
||||||
# get the PTZ config for the first onvif profile
|
|
||||||
configs = profile.PTZConfiguration
|
|
||||||
logger.debug(f"Onvif ptz config for media profile in {camera_name}: {configs}")
|
|
||||||
|
|
||||||
request = ptz.create_type("GetConfigurationOptions")
|
request = ptz.create_type("GetConfigurationOptions")
|
||||||
request.ConfigurationToken = profile.PTZConfiguration.token
|
request.ConfigurationToken = profile.PTZConfiguration.token
|
||||||
ptz_config = ptz.GetConfigurationOptions(request)
|
ptz_config = ptz.GetConfigurationOptions(request)
|
||||||
|
Loading…
Reference in New Issue
Block a user