使用pyinstaller将脚本转换为独立可执行文件时,无法捕获RTSP流 [英] Capturing RTSP stream fails when the script is turned into a standalone executable using pyinstaller

查看:189
本文介绍了使用pyinstaller将脚本转换为独立可执行文件时,无法捕获RTSP流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码:

from imutils.video import VideoStream
import cv2

# Read rtsp stream
rtsp = u"rtsp://admin:admin@10.64.1.31:554/1/h264major"
#vs = VideoStream(src=0).start() # for capturing from webcam
vs = VideoStream(src=rtsp).start()

while True:
    frame = vs.read()

    # show the output frame
    cv2.imshow("Frame", frame)
    key = cv2.waitKey(1) & 0xFF

    # if the `q` key was pressed, break from the loop
    if key == ord("q"):
        break

# do a bit of cleanup
cv2.destroyAllWindows()
vs.stop()   

  1. 在使用opencv的VideoCapture [cap.isOpened()返回False]时,我也遇到了相同的问题
  2. 在两种情况下(例如cv2.VideoCapture(0)或VideoStream(src = 0).start())从网络摄像头捕获时,独立可执行文件都能正常工作
  3. 当在python中运行脚本(即不将其转换为独立的可执行文件)时,rtsp流捕获在两种情况下均能正常工作.
  4. rtsp流已在VLC播放器上进行了测试,并且工作正常.
  5. 我正在使用Python 3.6.2 | OpenCV 3.2.0 | Windows

这可能是由于RTSP链接的utf-8等编码问题引起的吗?还有其他选择吗?

Could this be due to utf-8 etc encoding issues of the RTSP link? Any other alternatives?

已解决:我的可执行文件旁边包含opencv_ffmpeg320_64.dll.

Solved: Included opencv_ffmpeg320_64.dll next to my executable.

推荐答案

可执行文件旁边包含opencv_ffmpeg320_64.dll. 或者,将该dll文件复制到python目录中的DLLs文件夹中

Included opencv_ffmpeg320_64.dll next to my executable. Alternatively, copy that dll file to the DLLs folder in python directory

这篇关于使用pyinstaller将脚本转换为独立可执行文件时,无法捕获RTSP流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆