我想从我的python脚本发送OpenCV格式的处理帧到OBS Studio进行显示。我尝试使用here概述的Flask方法,并将生成的网页作为“浏览器”添加到OBS,但在我当前的Python代码中使用时,它存在错误且速度缓慢。
有没有办法直接将OpenCV帧流传输到OBS?例如,生成一个RTSP流,然后我可以在OBS中读取“VLC视频源”输入?
任何帮助将不胜感激。
框架代码:
import cv2
output_to_obs = True
output_to_cv2 = True
camera = cv2.VideoCapture(0)
def frame_to_obs(frame):
# ==========================
# don't know what to do here
# ==========================
pass
def process_frame(frame):
# just an example
frame_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
return frame_gray
while (camera.isOpened()):
ret, frame = camera.read()
if ret == True:
frame = process_frame(frame)
if output_to_obs:
frame_to_obs(frame)
if output_to_cv2:
cv2.imshow('frame',frame)
if cv2.waitKey(1) == 27:
# escape was pressed
break
else:
break
1条答案
按热度按时间tjvv9vkg1#
试试这个: