Onvif
Jump to navigation
Jump to search
onvif kamerų url (rtsp) aptikimas
Parodo visus galimus rtsp stream url'us.
pip3 install onvif-zeep git clone https://github.com/FalkTannhaeuser/python-onvif-zeep.git /tmp/python-onvif-zeep cp -r /tmp/python-onvif-zeep/wsdl \ ~/Library/Python/3.9/lib/python/site-packages/onvif/wsdl
scriptas get_rtsp.py:
from onvif import ONVIFCamera
CAMERA_IP = '192.168.1.100'
ONVIF_PORT = 8899
USERNAME = 'admin'
PASSWORD = '123456'
WSDL = '/Users/devnull/Library/Python/3.9/lib/python/site-packages/onvif/wsdl'
# connect to the camera
cam = ONVIFCamera(CAMERA_IP, ONVIF_PORT, USERNAME, PASSWORD, WSDL)
# create the media service
media = cam.create_media_service()
# get the first profile (you may have multiple profiles: RTSP often in profile[0])
profiles = media.GetProfiles()
# loop through each profile to get its RTSP URI
for idx, profile in enumerate(profiles):
# some cameras include a human-readable Name
name = getattr(profile, 'Name', f'Profile#{idx}')
token = profile.token
uri = media.GetStreamUri({
'StreamSetup': {
'Stream': 'RTP-Unicast',
'Transport': {'Protocol': 'RTSP'}
},
'ProfileToken': token
}).Uri
print(f'[{idx}] {name} (token={token})')
print(f' rtsp URL: {uri}\n')