python - 如何使用Camgear更改python中的帧率?

标签 python opencv youtube stream live

我的脚本打算显示YouTube直播

from vidgear.gears import CamGear
import cv2
url = 'https://youtu.be/o0Ryp4iWgOg'
stream = CamGear(source=url, y_tube =True,  time_delay=1, logging=True).start() 
# YouTube Video URL as input
print(stream.framerate)

while True:

frame = stream.read()

if frame is None:

    break
b = cv2.resize(frame, (800, 600), fx=0, fy=0, interpolation=cv2.INTER_CUBIC)
cv2.imshow("LiveVid", b)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
    break

cv2.destroyAllWindows()
stream.stop

几秒钟后,流停止。我认为高帧频会导致此问题。所以我想更改帧速率。我怎么做?

最佳答案

如果您想运行此代码,则必须将网址转换为其他YouTube直播流网址

关于python - 如何使用Camgear更改python中的帧率?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58609181/

相关文章:

c++ - opencv4tegra : issues compiling sample stereo_match. cpp

ios - 嵌入 Youtube 和 Vimeo 视频

youtube - 使用Youtube API代替Youtube抓取工具

python - seaborn 的 lmplot : KeyError [ . ..] 不在索引中; excel 和 csv 导入

python - 欧拉计划#10

python - lxml - 难以解析 stackexchange rss 提要

c++ - 在一个 OpenCV 中显示不同的窗口

2 个移位图像与 OpenCV 的 C++ 互相关

flutter - 在 Flutter Web 中嵌入 Youtube 视频

python - 使用 pyinstaller 问题编译 Windows 服务