Created
March 4, 2019 17:53
-
-
Save kingardor/285296ec94580ea0a96e638ed075e953 to your computer and use it in GitHub Desktop.
Access RTSP or UDP video stream that is streamed using FFMPEG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ffmpeg -i video.mp4 -v 0 -vcodec mpeg4 -f mpegts udp://192.168.0.101:23000 | |
import os | |
cap = cv2.VideoCapture('udp://192.168.0.101:23000?overrun_nonfatal=1&fifo_size=50000000') | |
# cap = cv2.VideoCapture('rtsp://192.168.0.101') | |
os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "udp_transport;0" | |
# os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;0" | |
while cap.isOpened(): | |
ret, frame = cap.read() | |
if ret: | |
cv2.imshow('Test', frame) | |
if cv2.waitKey(1) & 0xFF == ord('q'): break | |
cap.release() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment