'how to connect to rtsp camera from docker container?
I'm trying to get stream from IP camera with the help of openCV. Non-docker app runs fine on my PC, but i need to run it in a docker container. Here is my Dockerfile:
FROM jjanzic/docker-python3-opencv
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
CMD ["./CameraMan.py"]
src = 'rtsp://admin:....'
cap = cv2.VideoCapture(self.src)
cap.isOpened()
When i run the container, the last line always returns false. What am i missing?
Solution 1:[1]
you need to set the ip in "rtsp://user:pass@ip:port/.." to 0.0.0.0. So in you python script set:
src = "rtsp://user:[email protected]:554/..."
and you need to map your host rtsp host port '554' to the container port '554'. So call you container as follow:
docker run -p 554:554 youDockerName
Hope this solves the problem!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Moha Krs |