首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >解码MB 171时出错,% 1,bytestream -27

解码MB 171时出错,% 1,bytestream -27
EN

Stack Overflow用户
提问于 2020-10-21 21:03:18
回答 1查看 742关注 0票数 0

我有一个应用程序,在里面我可以从hikvision摄像头读取两个RTSP流,然后用它来做事情。有两个流,因为它是热像仪,它有两个流,一个正常流和一个热流。我是这样读这些流的:

代码语言:javascript
复制
import cv2
normal_path = "rtsp://adress@192.168.1.120/Streaming/channels/102"
thermal_path = "rtsp://adress@192.168.1.120/Streaming/channels/201"
normal_capture = cv2.VideoCapture(normal_path)
thermal_capture = cv2.VideoCapture(thermal_path)
while True:
    try:
        ret,thermal_frame = thermal_capture.read(0)
        ret1,normal_frame = normal_capture.read(0)
        #do a lot of things
    except:
        continue

normal_capture.release()
thermal_capture.release()
cv2.destroyAllWindows()

问题是,在一段时间后,例如,在应用程序正常工作的5个小时后,它收到如下错误:

代码语言:javascript
复制
[h264 @ 0x2ac51c0] error while decoding MB 17 1, bytestream -27

你知道为什么会发生这种事吗?你知道为什么这个错误会在try和except中出现吗?

EN

回答 1

Stack Overflow用户

发布于 2021-01-23 08:24:25

我在单个流中遇到了同样的问题,尽管我遇到的时间要早得多(在流中只有几分钟)。我通过检查ret是否不是True来处理它,如果是,则重新构建流。

代码语言:javascript
复制
import cv2
thermal_path = "rtsp://adress@192.168.1.120/Streaming/channels/201"
thermal_capture = cv2.VideoCapture(thermal_path)
while True:

    ret, thermal_frame = thermal_capture.read(0)
    if not ret:
        thermal_capture.release()
        thermal_capture = cv2.VideoCapture(thermal_path)
        print('Found error; rebuilding stream')

    #do a lot of things

thermal_capture.release()
cv2.destroyAllWindows()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64464169

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档