python - 使用 pyinstaller 将脚本转换为独立可执行文件时捕获 RTSP 流失败

标签 python pyinstaller rtsp opencv3.0

代码:

from imutils.video import VideoStream
import cv2

# Read rtsp stream
rtsp = u"rtsp://admin:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9efffaf3f7f0deafaeb0a8aab0afb0adaf" rel="noreferrer noopener nofollow">[email protected]</a>: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() returns False ]
  2. 在两种情况下,即 cv2.VideoCapture(0) 或 VideoStream(src=0).start() 从网络摄像头捕获时,独立可执行文件都可以正常工作
  3. 当脚本在 python 中运行时,rtsp 流捕获在这两种情况下都可以正常工作,即无需将其转换为独立的可执行文件。
  4. rtsp 流已在 VLC 播放器上进行测试,运行良好。
  5. 我正在使用 Python 3.6.2 | OpenCV 3.2.0 |窗口

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

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

最佳答案

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

关于python - 使用 pyinstaller 将脚本转换为独立可执行文件时捕获 RTSP 流失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47475130/

相关文章:

python - 带有特定 python 库的 spark-submit

python - 如何让progame只启动一个进程?

qt - 在 Windows 上的 QML 中播放 RTSP 视频

python - 在按下的每个键上实现自动建议

python - 外部命令 C 和 Python

python - 使用动态库的机器人框架自定义关键字中的 run_keyword 方法中的实现问题

python - 有没有办法在另一个 .py 文件中使用 PyInstaller?

python - PyInstaller 构建的 Windows EXE 因多处理而失败

android - 多个 Libstreaming 流仅被识别为第一个 RTSP 客户端的 session

ffmpeg - 从 RTSP 流中抓取一系列帧