0

这是我正在使用的代码:

 import cv2 
from time import time
import socket
from goprocam import GoProCamera, constants

WRITE = False
gpCam = GoProCamera.GoPro()
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
t=time()
gpCam.livestream("start")
gpCam.video_settings(res='1080p', fps='30')
gpCam.gpControlSet(constants.Stream.WINDOW_SIZE, constants.Stream.WindowSize.R720)
cap = cv2.VideoCapture("udp://10.5.5.9:8554", cv2.CAP_)
counter = 0
while True:
    ret, frame = cap.read()
    cv2.imshow("GoPro OpenCV", frame)
    #if WRITE == True:
        #cv2.imwrite(str(counter)+".jpg", frame)
        #counter += 1
        #if counter >= 10:
            #break
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
    if time() - t >= 2.5:
        sock.sendto("_GPHD_:0:0:2:0.000000\n".encode(), ("10.5.5.9", 8554))
        t=time()
# When everything is done, release the capture
cap.release()
cv2.destroyAllWindows() 

当我运行代码时,相机连接并显示实时画面,但终端给了我这个:

Camera successfully connected!
[h264 @ 000002963da53dc0] SPS unavailable in decode_picture_timing
[h264 @ 000002963da53dc0] non-existing PPS 0 referenced
[h264 @ 000002963da53dc0] SPS unavailable in decode_picture_timing
[h264 @ 000002963da53dc0] non-existing PPS 0 referenced
[h264 @ 000002963da53dc0] decode_slice_header error
[h264 @ 000002963da53dc0] no frame!
[h264 @ 000002963e3fa180] SPS unavailable in decode_picture_timing
[h264 @ 000002963e3fa180] non-existing PPS 0 referenced
[h264 @ 000002963e3fa180] decode_slice_header error
[h264 @ 000002963e3fa180] no frame!
[h264 @ 000002963dabd1c0] cabac decode of qscale diff failed at 70 37
[h264 @ 000002963dabd1c0] error while decoding MB 70 37, bytestream 1149
[h264 @ 000002963dabd1c0] cabac decode of qscale diff failed at 18 26
[h264 @ 000002963dabd1c0] error while decoding MB 18 26, bytestream 2393
[h264 @ 000002963dabcd80] cabac decode of qscale diff failed at 32 20
[h264 @ 000002963dabcd80] error while decoding MB 32 20, bytestream 1431
[h264 @ 000002963dabcd80] error while decoding MB 73 43, bytestream -6
[h264 @ 000002963dabd940] left block unavailable for requested intra4x4 mode -1
[h264 @ 000002963dabd940] error while decoding MB 0 24, bytestream 1809
[h264 @ 000002963e6cc8c0] cabac decode of qscale diff failed at 32 39
[h264 @ 000002963e6cc8c0] error while decoding MB 32 39, bytestream 10962
[h264 @ 000002963e3fa180] cabac decode of qscale diff failed at 25 41
[h264 @ 000002963e3fa180] error while decoding MB 25 41, bytestream 752
[h264 @ 000002963e6cc8c0] cabac decode of qscale diff failed at 54 37
[h264 @ 000002963e6cc8c0] error while decoding MB 54 37, bytestream 758
[h264 @ 000002963e604580] error while decoding MB 69 15, bytestream -6
[h264 @ 000002963e6cc8c0] error while decoding MB 41 43, bytestream -8
[h264 @ 000002963e604580] left block unavailable for requested intra mode
[h264 @ 000002963e604580] error while decoding MB 0 43, bytestream 129
[h264 @ 000002963e604580] left block unavailable for requested intra4x4 mode -1
[h264 @ 000002963e604580] error while decoding MB 0 44, bytestream 1522
[h264 @ 000002963dabcd80] left block unavailable for requested intra mode
[h264 @ 000002963dabcd80] error while decoding MB 0 42, bytestream 5129
[h264 @ 000002963dabd1c0] error while decoding MB 44 14, bytestream -6
[h264 @ 000002963dabd1c0] left block unavailable for requested intra mode
[h264 @ 000002963dabd1c0] error while decoding MB 0 26, bytestream 3910
[h264 @ 000002963dabd1c0] error while decoding MB 38 42, bytestream 130
[h264 @ 000002963dabd1c0] left block unavailable for requested intra mode
[h264 @ 000002963dabd1c0] error while decoding MB 0 32, bytestream 1671
[h264 @ 000002963dabd1c0] left block unavailable for requested intra mode
[h264 @ 000002963dabd1c0] error while decoding MB 0 31, bytestream 3941
[h264 @ 000002963daedac0] left block unavailable for requested intra4x4 mode -1
[h264 @ 000002963daedac0] error while decoding MB 0 22, bytestream 6842
[h264 @ 000002963dabd940] left block unavailable for requested intra mode
[h264 @ 000002963dabd940] error while decoding MB 0 17, bytestream 5665
[h264 @ 000002963dabcd80] cabac decode of qscale diff failed at 75 31
[h264 @ 000002963dabcd80] error while decoding MB 75 31, bytestream 2273

我怀疑它与这条线有关:

cap = cv2.VideoCapture("udp://10.5.5.9:8554", cv2.CAP_FFMPEG)

但我不确定。

此外,实时馈送非常缓慢且模糊,但我认为这只是无线连接的结果。有人对如何阻止这些错误有任何建议吗?

4

0 回答 0