zyw
March 22, 2022, 8:00am
1
I try to open two rtsp streams with two seperate threads,each thread execute the same function of connecting a rtsp stream ,and calculating the consuming time . I think I could get roughly equivalent spending time , but actually , it seems to be a accumulation. For example,thread 1 spends 1.3 seconds,thread 2 spends 2.7 seconds, and thread 3 spends 4.1 seconds and so on . It seems to be a a serial operation, not parallel work . I guess there must be something like synchronization mechanisms in VideoCapture that I didn’t know . can anybody explain it for me ? Thanks very much !
def action2(name, source_address):
try:
start = time.time()
cap = cv2.VideoCapture(source_address)
print(f'{name}cost {time.time() - start}')
except Exception as e:
print(f'{e}')
return None
if __name__ == '__main__':
source_address = f'rtsp://user:passwd@ip:port/live'
source_address2 = f'rtsp://user:passwd@ip:port/live'
action2('thread1', source_address)
action2('thread2', source_address2)
output :
thread1 cost 1.332
thread2 cost 2.834
Opening the stream is serial but processing is not. See this issue
opened 03:39PM - 18 May 21 UTC
category: videoio
category: 3rdparty
On windows when opening up RTSP streams with VideoCapture::open() and the FFMPEG… back end, there is normally a delay, say 2000ms while the stream is setup, which is to be expected.
While this is happening any additional calls to VideoCapture::open() and VideoWriter.open() in other threads are blocked.
Is this blocking/queuing part of OpenCV or FFMPEG and can it be removed?
##### System information (version)
- OpenCV => 4.5.2
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2019
##### Steps to reproduce
<!-- to add code example fence it with triple backticks and optional file extension
```.cpp
// C++ code example
```
or attach as .txt or .zip file
-->
##### Issue submission checklist
- [* ] I report the issue, it's not a question
<!--
OpenCV team works with forum.opencv.org, Stack Overflow and other communities
to discuss problems. Tickets with question without real issue statement will be
closed.
-->
- [ *] I checked the problem with documentation, FAQ, open issues,
forum.opencv.org, Stack Overflow, etc and have not found solution
<!--
Places to check:
* OpenCV documentation: https://docs.opencv.org
* FAQ page: https://github.com/opencv/opencv/wiki/FAQ
* OpenCV forum: https://forum.opencv.org
* OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
* Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
-->
- [ ] I updated to latest OpenCV version and the issue is still there
<!--
master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
OpenCV team supports only latest release for each branch.
The ticket is closed, if the problem is not reproduced with modern version.
-->
- [ ] There is reproducer code and related data files: videos, images, onnx, etc
<!--
The best reproducer -- test case for OpenCV that we can add to the library.
Recommendations for media files and binary files:
* Try to reproduce the issue with images and videos in opencv_extra repository
to reduce attachment size
* Use PNG for images, if you report some CV related bug, but not image reader
issue
* Attach the image as archive to the ticket, if you report some reader issue.
Image hosting services compress images and it breaks the repro code.
* Provide ONNX file for some public model or ONNX file with with random weights,
if you report ONNX parsing or handling issue. Architecture details diagram
from netron tool can be very useful too. See https://lutzroeder.github.io/netron/
-->