title: Have trouble streaming RTP/ RTSP stream from OpenCV-Python
body: <p>I am trying to use this sample script I found here in order to take OpenCV images and convert them into a rtp/rtsp stream:<br>
  <a href="https://github.com/madams1337/python-opencv-gstreamer-examples/blob/master/gst_device_to_rtp.py" rel="noreferrer">https://github.com/madams1337/python-opencv-gstreamer-examples/blob/master/gst_device_to_rtp.py</a></p>
  
  <p>Where this is the description of the script:</p>
  
  <p>"gst_device_to_rtp grabs the VideoCapture(0),encodes the frame and streams it to rtp://localhost:5000"</p>
  
  <p>This is the code I am trying to use</p>
  
  <pre><code># Cam properties
  fps = 30.
  frame_width = 1920
  frame_height = 1080
  # Create capture
  
  #cap = cv2.VideoCapture(0)
  
  # Set camera properties
  cap.set(cv2.CAP_PROP_FRAME_WIDTH, frame_width)
  cap.set(cv2.CAP_PROP_FRAME_HEIGHT, frame_height)
  cap.set(cv2.CAP_PROP_FPS, fps)
  
  # Define the gstreamer sink
  gst_str_rtp = "appsrc ! videoconvert ! x264enc noise-reduction=10000 tune=zerolatency byte-stream=true threads=4 " \
                " ! h264parse ! mpegtsmux ! rtpmp2tpay ! udpsink host=127.0.0.1 port=5000"
  
  # Create videowriter as a SHM sink
  out = cv2.VideoWriter(gst_str_rtp, 0, fps, (frame_width, frame_height), True)
  
  # Loop it
  while True:
      # Get the frame
      ret, frame = cap.read()
  
      # Check
      if ret is True:
          # Flip frame
          frame = cv2.flip(frame, 1)
          # Write to SHM
          out.write(frame)
      else:
          print "Camera error."
          time.sleep(10)
  
  cap.release()
  </code></pre>
  
  <p>Mainly this code, which specifies the gstreamer pipeline configuration:</p>
  
  <pre><code># Define the gstreamer sink
  gst_str_rtp = "appsrc ! videoconvert ! x264enc noise-reduction=10000 tune=zerolatency byte-stream=true threads=4 " \
                " ! h264parse ! mpegtsmux ! rtpmp2tpay ! udpsink host=127.0.0.1 port=5000"
  
  # Create videowriter as a SHM sink
  out = cv2.VideoWriter(gst_str_rtp, 0, fps, (frame_width, frame_height), True)
  </code></pre>
  
  <p>From what I understand, it is sending the OpenCV video images to "rtp://localhost:5000"</p>
  
  <p>However, whenever I try to execute this terminal command in terminal while I leave the script running:</p>
  
  <pre><code>ffplay 'rtp://localhost:5000'
  </code></pre>
  
  <p>It just hangs forever like this:
  <a href="https://i.stack.imgur.com/r6wYp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/r6wYp.png" alt="enter image description here"></a>
  And I can't really determine what that really means. Does it mean that it can connect to localhost at that port, but found nothing there? I don't really know. The command seems works if there is another with other rtsp urls, but not this one.</p>
  
  <p>And if I try "ffplay 'rtsp://localhost:5000'", then I just get a Connection Refused error (maybe nothing is being generated at that stream)</p>
  
  <p>Does the script really output a rtp stream to localhost:5000? Or is there problems with my ffplay on my machine? Or is there a special ffplay command I should execute? What should I do?</p>