I've been in a war to get this issue resolved. I have the impression that I have already searched the entire internet... My goal is to send an rtsp stream from my host (Windows) to a Docker container, to later run machine learning models on the video.
Host (Windows):
Thanks to rtsp-simple-server I'm able to get my webcam to generate an rtsp stream. The rtsp-simple-server.yml looks like (where xxx.xxx.xxx.x is the Windows Host IP):
paths:
cam:
runOnInit: ffmpeg -f dshow -i video="HP HD Camera" -c:v libx264 -preset ultrafast -tune zerolatency -b:v 600k -f rtsp rtsp://xxx.xxx.xxx.x:8554/cam
runOnInitRestart: yes
Then I can view the video running a script in python that opens a window for me:
import cv2
import os
os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;tcp"
vcap = cv2.VideoCapture("rtsp://localhost:8554/cam", cv2.CAP_FFMPEG)
while(1):
ret, frame = vcap.read()
if ret == False:
print("Frame is empty")
break;
else:
cv2.imshow('VIDEO', frame)
cv2.waitKey(1)
Docker container:
Now comes the tricky part: How can I get the stream to the Docker container? I am currently using the Docker image: jjanzic/docker-python3-opencv but when I run the python script I get "Frame is empty"... Even changing the rtsp://localhost:8554/cam by the Windows Host IP - rtsp://xxx.xx.xxx.x:8554/cam
Help please
