【发布时间】:2019-12-31 20:06:14
【问题描述】:
我创建了一个 python 程序,使用 OpenCV 和 GStreamer 将帧流式传输到 GStreamer udpsink。这是代码:
import cv2
import config
def send():
cap = cv2.VideoCapture(0) #open the camera
fourcc = cv2.VideoWriter_fourcc(*'H264')
out = cv2.VideoWriter('appsrc ! videoconvert ! x264enc tune=zerolatency noise-reduction=10000 bitrate=2048 speed-preset=superfast ! rtph264pay config-interval=1 pt=96 ! udpsink host=127.0.0.1 port=5000',fourcc,config.CAP_PROP_FPS, (800,600),True) #ouput GStreamer pipeline
if not out.isOpened():
print('VideoWriter not opened')
exit(0)
while cap.isOpened():
ret,frame = cap.read()
if ret:
# Write to pipeline
out.write(frame)
if cv2.waitKey(1)&0xFF == ord('q'):
break
cap_send.release()
out_send.release()
send()
然后,在我的终端中,我的 GStreamer 接收器管道是:
gst-launch-1.0 -v udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! decodebin ! videoconvert ! autovideosink
问题是我收到的帧是这样的: https://drive.google.com/open?id=14PeiGlEfcSuzRjSPENrCjGQIQk-04OHb
我想这都是关于 openCV 中的色彩空间转换...你觉得呢? 谢谢!
【问题讨论】:
-
有什么理由禁用RGB转换cap.set(cv2.CAP_PROP_CONVERT_RGB, False) ?
-
是的,很抱歉我删除了这一行,但问题仍然存在......
标签: python opencv gstreamer h.264