Hi, I try your suggestion and the multicast also.
It only works in the same Jetson.
When I try to open the sdp file using another board or PC, it didn’t works.
I try to change the cv2.VideoCapture(0)
to:
gst_cap = “v4l2src device=/dev/video0 ! video/x-raw, format=(string)YUY2, width=(int)640, height=(int)480, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw(memory:NVMM), format=(string)NV12 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink”
cap = cv2.VideoCapture(gst_cap, cv2.CAP_GSTREAMER)
is this correct for usb webcam?
Thank you
The complete python:
import cv2
gst_cap = “v4l2src device=/dev/video0 ! video/x-raw, format=(string)YUY2, width=(int)640, height=(int)480, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw(memory:NVMM), format=(string)NV12 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink”
cap = cv2.VideoCapture(gst_cap, cv2.CAP_GSTREAMER)
gst_out = “appsrc ! video/x-raw, format=BGR, pixel-aspect-ratio=1/1 ! queue ! videoconvert ! video/x-raw, format=BGRx ! nvvidconv ! nvv4l2h264enc insert-vui=1 ! video/x-h264, stream-format=byte-stream, alignment=au ! h264parse ! video/x-h264, stream-format=byte-stream ! rtph264pay pt=96 config-interval=1 ! application/x-rtp, media=video, encoding-name=H264 ! udpsink host=224.1.1.1 port=5000 auto-multicast=true”
out = cv2.VideoWriter(gst_out, cv2.CAP_GSTREAMER, 0, 20, (640, 480))
if not out.isOpened() :
print(“Writer failed”)
exit()
print(‘Writer opened’)
while True:
ret,frame = cap.read()
if not ret:
break
#cv2.imshow("Image", frame)
out.write(frame)
cv2.waitKey(5)
out.release()
cap.release()
The sdp file:
c=IN IP4 224.1.1.1
m=video 5000 RTP/AVP 96
a=rtpmap:96 H264/90000
It works in the same board only.