1

Updated: I have a rpi compute module which successfully gstreams video, using the cmd line. Jetson machine receives it using cmd line too (but not a python script!)

On the RPi:

raspivid -fps 15 -b 400000 -t 0 -n -w 640 -h 480 -o - | tee | gst-launch-1.0 
-v fdsrc ! h264parse ! rtph264pay config-interval=1 ! udpsink 
host=192.168.1.111 port=5000

On the Jetson TX2 cmd line I run:

gst-launch-1.0 udpsrc port=5000 ! 'application/x-rtp, encoding-name=H264, 
payload=96' ! rtph264depay ! h264parse ! avdec_h264 ! xvimagesink sync=false

From this I can see the gstreamer video coming up on the Jetson desktop (ubuntu) so it works!

I created a python script to open a cv2.cap and print statements to let me know how things are going, my real goal is to do something with the frames (cv2 processing).

import cv2
import numpy as np

print "start"

cap = cv2.VideoCapture("udpsrc port=5000 ! 'application/x-rtp, encoding-
name=H264, payload=96' ! rtph264depay ! h264parse ! avdec_h264 ! ! appsink", 
cv2.CAP_GSTREAMER)

print "check1"
while(cap.isOpened()):
   print "check2"
   frame = cap.read()

cap.release()
cv2.destroyAllWindows()

What I get out is now:

(python:3608): GStreamer-CRITICAL **: gst_element_make_from_uri: assertion 
'gst_uri_is_valid (uri)' failed
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file 
/home/nvidia/opencv/modules/videoio/src/cap_gstreamer.cpp, line 881
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised 
OpenCV exception:

/home/nvidia/opencv/modules/videoio/src/cap_gstreamer.cpp:881: error: (-2) 
GStreamer: unable to start pipeline
in function cvCaptureFromCAM_GStreamer

I did a test with a local file and it works (prints "loop" constantly):

cap = cv2.VideoCapture("filesrc location=/home/nvidia/comp/grill-mjpeg.mov ! 
appsink", cv2.CAP_GSTREAMER)

The only differences here is the UDP vs local file, and the type of encoding? But the encoding options worked in the cmd line. Any ideas to get this script working?

Any help would be greatly appreciated!

Fred
  • 53
  • 6
  • try adding autovideosink after avdec_h264 and see if the video is displayed. – Prabhakar Lad Jan 30 '18 at 08:30
  • I confirm I have working video now, I have added the new RPi code and the Jetson code that works in the command line. However this still doesn't work in the python script – Fred Jan 30 '18 at 11:27
  • replace the appsink to autovideosink in the script. – Prabhakar Lad Jan 30 '18 at 11:29
  • From that I get this: `/cap_gstreamer.cpp:796: error: (-2) GStreamer: cannot find appsink in manual pipeline in function cvCaptureFromCAM_GStreamer" ` And no success like the local file does – Fred Jan 30 '18 at 11:39
  • I am not familiar with python bindings, unless you really want it from python, you can use gst_parse_launch() in c and get your command line pipeline working with it. – Prabhakar Lad Jan 30 '18 at 11:59
  • Yeah it looks like the whole problem is the python bindings. I've read some examples of this but it looks like you need to declare a lot. Do you have any very simple examples of loading from a file e.g. home/test.avi ? Thanks – Fred Jan 30 '18 at 14:29
  • could you describe a bit more to do what just load from file ? – Prabhakar Lad Jan 30 '18 at 14:31
  • Yes: load the file using gstreamer and OpenCV and read some frames and print the shape. Something super basic. (doesn't need to display). Thanks – Fred Jan 30 '18 at 14:40

0 Answers0