简体   繁体   中英

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?

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:pass@0.0.0.0: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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM