Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

gstreamer output with VideoWriter?

Hi, is it possible to use VideoWriter to output directly to gstreamer, something like below? It would be a lot simpler than pushing buffers to appsrc, which I can't find any working code for (python, gstreamer 1.0).

#!/usr/bin/python
import time, os, sys
import cv2
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
stream = cv2.VideoWriter("appsrc ! x264enc ! h264parse ! rtph264pay config-interval=1 pt=96 ! udpsink host=192.168.1.x port=5000 sync=false", fourcc, 30, (1280,720))
capture = cv2.VideoCapture("v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=720,framerate=30/1 ! decodebin ! videoconvert ! appsink")
while True:
    ret,frame=capture.read()
    stream.write(frame)
capture.release()
stream.release()
cv2.destroyAllWindows()