Skip to content

Instantly share code, notes, and snippets.

@gyillikci
Created October 31, 2024 14:38
Show Gist options
  • Save gyillikci/b4483c6055a1c2ddb444c38a50bd0d66 to your computer and use it in GitHub Desktop.
Save gyillikci/b4483c6055a1c2ddb444c38a50bd0d66 to your computer and use it in GitHub Desktop.
from onvif import ONVIFCamera
# Replace with your camera's details
camera = ONVIFCamera('192.168.1.100', 80, 'username', 'password')
# Create media service
media_service = camera.create_media_service()
# Get the profiles
profiles = media_service.GetProfiles()
token = profiles[0].token
# Create PTZ service
ptz_service = camera.create_ptz_service()
# Get the current PTZ status
status = ptz_service.GetStatus({'ProfileToken': token})
# Print the current focal length
print(f"Current focal length: {status.Position.Zoom.x}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment