4

I'm trying to stream some images form opencv using gstreamer and I got some issues with the pipeline. I'm new to gstreamer and opencv in general. I compiled opencv 3.2 with gstreamer for python3 on a raspberry pi 3. I have a little bash script that I use with raspivid

raspivid -fps 25 -h 720 -w 1080 -vf -n -t 0 -b 2000000 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=192.168.1.27 port=5000

I wanted to translate this pipeline in order to use it from opencv and feed it images that my algorithm manipulates. I did some research and figured that I can use videoWriter with appsrc instead of fdsrc but I get the following error

GStreamer Plugin: Embedded video playback halted; module appsrc0 reported: Internal data flow error.

The python script that I came up with is the following by the way import cv2

cap = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
out = cv2.VideoWriter('appsrc ! h264parse ! '
 'rtph264pay config-interval=1 pt=96 ! '
 'gdppay ! tcpserversink host=192.168.1.27 port=5000 ',
 fourcc, 20.0, (640, 480))
while cap.isOpened():
 ret, frame = cap.read()
 if ret:
 frame = cv2.flip(frame, 0)
 # write the flipped frame
 out.write(frame)
 if cv2.waitKey(1) & 0xFF == ord('q'):
 break
 else:
 break
# Release everything if job is finished
cap.release()
out.release()
cv2.destroyAllWindows()

Are there any errors in the pipeline? I don't understand the error. I already have a Python client that can read from the bash pipeline and the results are pretty good from the latency perspective and consumed resources.

Quintin B
6891 gold badge5 silver badges20 bronze badges
asked Aug 8, 2017 at 13:45

1 Answer 1

2

Please add videoconvert after appsrc as you need to convert format of the video to display it on autovideosink or stream it using udpsink. It could be something like this:

video = cv2.VideoWriter('appsrc ! queue ! videoconvert ! video/x-raw ! omxh264enc ! video/x-h264 ! h264parse ! rtph264pay ! udpsink host=192.168.0.2 port=5000 sync=false',0,25.0,(640,480))
SlySven
3,6311 gold badge20 silver badges46 bronze badges
answered Dec 18, 2017 at 15:21
1
  • Welcome to the Raspberry Pi flavoured corner of the Stack Exchange network - you might like to take the tour to improve your experience on SE. Commented Dec 19, 2017 at 3:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.