如何解决通过 OpenCV 在 m3u8 流中无效的 NAL 单元大小
从指向 10 个已排序的“.m4s”视频文件的 Raspberry Pi 零 W 流式传输“.m3u8”提要。 将其输入下面的 cv2 库时,它会抛出本文底部显示的错误代码。 这些错误似乎与输出视频挂起/卡顿同步。
代码:
import cv2
import sys
import random
faceCascade = [cv2.CascadeClassifier(x) for x in sys.argv[1:]]
video_capture = cv2.VideoCapture('http://*IP*:8080/camera/livestream.m3u8')
colors = [(random.randint(0,255),random.randint(0,255)) for i in faceCascade]
while True:
# Capture frame-by-frame
ret,frame = video_capture.read()
gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
faces = [list(face)+[i] for i,faces in enumerate(faceCascade) for face in faces.detectMultiScale(
gray,scaleFactor=1.1,minNeighbors=5,minSize=(30,30),flags=cv2.CASCADE_SCALE_IMAGE
)]
# Draw a rectangle around the faces
for (x,y,w,h,i) in faces:
cv2.rectangle(frame,(x,y),(x+w,y+h),colors[i],2)
# Display the resulting frame
cv2.imshow('Video',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything is done,release the capture
video_capture.release()
cv2.destroyAllWindows()
错误:
[h264 @ 00000189507870c0] Invalid NAL unit size (2103052861 > 20986).
[h264 @ 00000189507870c0] Error splitting the input into NAL units.
有没有办法用流解决这些错误?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。