Pulling VOD Stream from Milestone ONVIF bridge server

Hello Team:

I have a milestone server 2019 R2, have bridge server installed

I’m trying to connect to bridge server to get recording summary using python

The code is as below

from zeep import Client

# Define the ONVIF device’s host IP address

host = ‘10.xx.xx.xx:554’

# Create a Zeep client for the ONVIF service

search_endpoint = f’http://{host}/onvif/recording_search_service

client = Client(search_endpoint)

# Create the request and response objects

GetRecordingSummary = client.get_type(‘ns0:GetRecordingSummary’)

GetRecordingSummaryResponse = client.get_type(‘ns0:GetRecordingSummaryResponse’)

request = GetRecordingSummary()

# Call the GetRecordingSummary operation

response = client.service.GetRecordingSummary(_soapheaders={‘username’: ‘EXT.username’, ‘password’: ‘passowrd’}, _soapheadersnumbers={‘WSU:Timestamp’: 1}, _soapheadersstrings={‘Action’: ‘your_action’}, _soapheaderscustom={})

result = response.SearchResult

print(f"Search Result: {result}")

Question (s):

  1. i belive the connection to GetRecordingSummary page should be HTTP/ HTTPS not RTSP. Our implementation partner says RTSP Can provide this info, I doubt that hence asking the question here
  2. Does Milesone 2019 R2 offer this feature
  3. If i wanted to useing OpenCV to stream VOD from a particular time, assume wanted to to get last 1 hour of recording, how do i do so

one more, i can play the VOD stream using my RTSP program, but i can’t skip to cerain frame or time, but i can do it via VLC example

----------

this command works

vlc.exe --rate=1.0 --start-time=72000 “rtsp://user:password@10.xx.xx.xx:554/vod/983A2D61-8915-4840-BC71-23B418D0AD69”

--------

my RTSP program don’t work

import cv2

# Open a video capture object

cap = cv2.VideoCapture(‘tsp://user:password@10.xx.xx.xx:554/vod/983A2D61-8915-4840-BC71-23B418D0AD69’)

# Check if the video stream is opened successfully

if not cap.isOpened():

print("Error: Could not open video stream.")

exit()

# List of known property IDs and their descriptions

property_names = {

cv2.CAP\_PROP\_POS\_MSEC: 'Current position in milliseconds',

cv2.CAP\_PROP\_POS\_FRAMES: '0-based index of the next frame to be captured or decoded',

cv2.CAP\_PROP\_POS\_AVI\_RATIO: 'Relative position in the video file (0.0 to 1.0)',

cv2.CAP\_PROP\_FRAME\_WIDTH: 'Width of frames in the video stream',

cv2.CAP\_PROP\_FRAME\_HEIGHT: 'Height of frames in the video stream',

cv2.CAP\_PROP\_FPS: 'Frames per second (FPS) of the video stream',

cv2.CAP\_PROP\_FRAME\_COUNT: 'Total number of frames in the video stream',

cv2.CAP\_PROP\_FOURCC: 'FourCC code of the codec used in the video stream',

cv2.CAP\_PROP\_BRIGHTNESS: 'Brightness setting (for cameras)',

cv2.CAP\_PROP\_CONTRAST: 'Contrast setting (for cameras)',

cv2.CAP\_PROP\_SATURATION: 'Saturation setting (for cameras)',

# Add more properties as needed

}

# Iterate through the property IDs and print their values

for prop_id, prop_description in property_names.items():

prop\_value = cap.get(prop\_id)

print(f"{prop\_description} ({prop\_id}): {prop\_value}")

[#Get](javascript:void(0); “#Get”) the total frames

total_frames = cap.get(cv2.CAP_PROP_FRAME_COUNT)

fps = cap.get(cv2.CAP_PROP_FPS)

seconds_to_go_back = 60*60*24

frame_offset = fps*seconds_to_go_back

print(frame_offset)

start_frame_for_Video = total_frames-frame_offset

print(start_frame_for_Video)

initial_read = True

while True:

# Read a frame from the video stream

ret, frame = cap.read()

if not ret:

    print("Error: Could not read frame.")

    break

# Do something with the frame, e.g., display it

cv2.imshow('Video Stream', frame)

# Break the loop if the 'q' key is pressed

if cv2.waitKey(1) & 0xFF == ord('q'):

    break

if initial\_read:

    # Set the frame position using the CAP\_PROP\_POS\_FRAMES property

    print(cap.get(cv2.CAP\_PROP\_POS\_FRAMES))

    cap.set(cv2.CAP\_PROP\_POS\_FRAMES, int(frame\_offset))

    print(cap.get(cv2.CAP\_PROP\_POS\_FRAMES))

    initial\_read = False

# Release the video capture object and close any OpenCV windows

cap.release()

cv2.destroyAllWindows()

-- the program always starts from first frame in the vod recording

Hi @Thiru PS

  1. You are right. GetRecordingSummary command is part of the ONVIF specification, not part of RTSP. However there is an alternative approach to receive this information over RTSP. See this forum thread for more info.
  2. Yes, but this version is out of support for several years. Consider upgrading your system to the latest version.
  3. This forum thread explains how to ask for recordings from a particular time slot.

Br,

Nikolay

Thanks Nikolay,

Appreciate your time.

We are using python/ open CV to connect to RTSP Stream, do know the implementation for the same? for passing header.

From My understanding we cannot pass on OpenCV

I’m not familiar with OpenCV or with Python, sorry.

Br,

Nikolay