我先用VLC发RTSP视频流,视频格式为mp4,该视频流可以用另一个VLC成功接收并播放,而我用python的opencv库写的代码不能成功读取,该代码可以成功读取本地视频。
代码如下:
import cv2
video_full_path = "rtsp://cky:30121323@10.133.183.133:8554/1"
cap = cv2.VideoCapture(video_full_path)
print(cap.isOpened())
frame_count = 1
success = True
while (success):
success, frame = cap.read()
print(frame)
print('Read a new frame: ', success)
params = []
# params.append(cv.CV_IMWRITE_PXM_BINARY)
params.append(1)
cv2.imwrite("video" + "_%d.jpg" % frame_count, frame, params)
frame_count = frame_count + 1
cap.release()
望解决。