Ask Your Question
0

gstreamer output with VideoWriter?

asked 2016-06-11 02:30:14 -0600

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()
edit retag flag offensive close merge delete

Comments

Did you get the streaming to work?

ThomCastel gravatar imageThomCastel ( 2016-10-05 07:54:59 -0600 )edit

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

berak gravatar imageberak ( 2016-10-05 08:40:46 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2017-01-04 04:53:42 -0600

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.

edit flag offensive delete link more

Comments

it gives me: no element "v4l2video1h264enc"

stiv-yakovenko gravatar imagestiv-yakovenko ( 2019-10-18 07:43:02 -0600 )edit
0

answered 2017-12-18 09:16:53 -0600

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

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-06-11 02:29:36 -0600

Seen: 10,489 times

Last updated: Oct 05 '16