0

我尝试使用 OpenCV 打开 UDP 视频流,不幸的是,我收到一个错误,但是当我使用 FFmpeg 打开流时ffplay udp://127.0.0.1:46002一切正常。

这是我的代码:

import cv2

cap = cv2.VideoCapture('udp://127.0.0.1:46002', cv2.CAP_FFMPEG)
if not cap.isOpened():
    print('VideoCapture not opened')
    exit(-1)

while True:
    ret, frame = cap.read()
    if not ret:
        print('frame empty')
        break
    cv2.imshow('image', frame)
    if cv2.waitKey(1) & 0XFF == ord('q'):
         break

cap.release()
cv2.destroyAllWindows()

这是我得到的错误:

[h264 @ 1135fa40] no frame!
[h264 @ 1135fa40] non-existing PPS 0 referenced
[h264 @ 1135fa40] non-existing PPS 0 referenced
[h264 @ 1135fa40] decode_slice_header error
[h264 @ 1135fa40] non-existing PPS 0 referenced
[h264 @ 1135fa40] decode_slice_header error
[h264 @ 1135fa40] no frame!
[h264 @ 1135fa40] non-existing PPS 0 referenced
[h264 @ 1135fa40] non-existing PPS 0 referenced
[h264 @ 1135fa40] decode_slice_header error
[h264 @ 1135fa40] non-existing PPS 0 referenced
[h264 @ 1135fa40] decode_slice_header error
[h264 @ 1135fa40] no frame!
[h264 @ 1135fa40] non-existing PPS 0 referenced
[h264 @ 1135fa40] non-existing PPS 0 referenced
[h264 @ 1135fa40] decode_slice_header error
[h264 @ 1135fa40] non-existing PPS 0 referenced
[h264 @ 1135fa40] decode_slice_header error
[h264 @ 1135fa40] no frame!
4

0 回答 0