如何在opencv python中通过udp连接?

2024-06-28 18:50:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法通过udp gstreamer python进行连接。当我输入命令gst-launch-1.0 -v udpsrc port=3000 buffer-size=13000000 ! h264parse ! avdec_h264 ! d3dvideosink sync=false时。一切正常,但当我尝试通过python连接时,“无法打开视频”

import sys
import cv2

cap = cv2.VideoCapture("udpsrc port=3000 ! application/x-rtp,payload=96,encoding-name=H264 ! rtpjitterbuffer mode=1 ! rtph264depay ! h264parse ! decodebin ! videoconvert ! appsink", cv2.CAP_GSTREAMER);

if not cap.isOpened():
    print("Could not open video")
    sys.exit()

# Read first frame.
ok, frame = cap.read()
if not ok:
    print('Cannot read video file')
    sys.exit()

Tags: importreadifportvideosysexitnot