S
S
swpavlov2021-01-06 22:07:58
Python
swpavlov, 2021-01-06 22:07:58

How to make video output by udp opencv python?

I'm having trouble connecting via udp gstreamer python. When I enter the command

gst-launch-1.0 -v udpsrc port=3000 buffer-size=13000000 ! h264parse ! avdec_h264 ! d3dvideosink sync=false
. Everything works but when I try to connect via python "Could not open video"

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()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question