Ask Your Question
0

gstreamer output with VideoWriter?

asked Jun 11 '16

Fnoop gravatar image

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()
Preview: (hide)

Comments

Did you get the streaming to work?

ThomCastel gravatar imageThomCastel (Oct 5 '16)edit

@ThomCastel, please do not post answers, if you don't have any

berak gravatar imageberak (Oct 5 '16)edit

2 answers

Sort by » oldest newest most voted
0

answered Jan 4 '17

Fnoop gravatar image

I cannot for the life of me work out how to get this working in python. I have got it working in c++:

cv::VideoWriter writer;
writer.open("appsrc ! autovideoconvert ! v4l2video1h264enc extra-controls=\"encode,h264_level=10,h264_profile=4,frame_level_rate_control_enable=1,video_bitrate=2000000\" ! h264parse ! rtph264pay config-interval=1 pt=96 ! udpsink host=192.168.x.x port=5000 sync=false", 0, 30, cv::Size(640, 480 ), true);

Exactly the same thing in python either gives vague errors or just sits there doing nothing.

Preview: (hide)

Comments

it gives me: no element "v4l2video1h264enc"

stiv-yakovenko gravatar imagestiv-yakovenko (Oct 18 '19)edit
0

answered Dec 18 '17

techgeek09 gravatar image

Here is the working code for Opencv Python VideoWriter video = cv2.VideoWriter('appsrc ! queue ! videoconvert ! video/x-raw ! x264enc ! h264parse ! rtph264pay ! udpsink host="Receiver IP" port="Port" sync=false',0,25.0,(640,480))

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Jun 11 '16

Seen: 10,850 times

Last updated: Oct 05 '16