title: Issue reading RTSP stream with opencv and cv::cvtColor
body: <p>I am trying to capture rtsp stream with opencv but it complains about the cv2.COLOR_BGR2RGB.
  I have done several tries with streaming a different web-camera which working fine but not with the rtsp. The rtsp stream it self is working and tested fine with vlc. The rtsp stream it self is h264 format.</p>
  <p>But, if I remark in the lines with the if statement it false, because the frame is empty!</p>
  <pre><code>import os
  import cv2
  import time
  import argparse
  import multiprocessing
  import numpy as np
  import tensorflow as tf
  
  from utils.app_utils import FPS, WebcamVideoStream, HLSVideoStream
  from multiprocessing import Queue, Pool
  
  CWD_PATH = os.getcwd()
          
  if __name__ == '__main__':
      parser = argparse.ArgumentParser()
      parser.add_argument('-str', '--stream', dest=&quot;stream&quot;, action='store', type=str, default=None)
      parser.add_argument('-src', '--source', dest='video_source', type=int,
                          default=0, help='Device index of the camera.')
      parser.add_argument('-wd', '--width', dest='width', type=int,
                          default=640, help='Width of the frames in the video stream.')
      parser.add_argument('-ht', '--height', dest='height', type=int,
                          default=480, help='Height of the frames in the video stream.')
      parser.add_argument('-num-w', '--num-workers', dest='num_workers', type=int,
                          default=2, help='Number of workers.')
      parser.add_argument('-q-size', '--queue-size', dest='queue_size', type=int,
                          default=5, help='Size of the queue.')
      args = parser.parse_args()
  
      logger = multiprocessing.log_to_stderr()
      logger.setLevel(multiprocessing.SUBDEBUG)
  
      input_q = Queue(maxsize=args.queue_size)
      output_q = Queue(maxsize=args.queue_size)
  
      print('Reading from webcam.')
      #video_capture = WebcamVideoStream(src=&quot;rtsp://ip:port/stream&quot;,
      #                              width=args.width,
      #                              height=args.height).start()
  
      frame_width = args.width
      frame_height = args.height
      print('Width:', frame_width, 'Height:', frame_height)
      out = cv2.VideoWriter('output_test.avi', cv2.VideoWriter_fourcc('m','p','4','v'), 10, (frame_width,frame_height))
  
      vcap = cv2.VideoCapture(&quot;rtsp://ip:port/stream&quot;, cv2.CAP_FFMPEG)
      
      while True:
          ret, frame = vcap.read()
  
          #if ret == False:
          #    break
  
          # Our operations on the frame come here
          frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
          
          output_q.put(frame_rgb)
          # Convert and store to out file
          #output_rgb = cv2.cvtColor(output_q.get(), cv2.COLOR_RGB2BGR)
          #out.write(output_rgb)
          #cv2.imshow('VIDEO', output_rgb)
  
          # Display the resulting frame
          cv2.imshow('frame', frame_rgb)
          if cv2.waitKey(1) &amp; 0xFF == ord('q'):
              break
              
      #video_capture.stop()
      out.release()
      cv2.destroyAllWindows()
  </code></pre>
  <p>Which gives me an issue (without if statement):</p>
  <pre><code>[DEBUG/MainProcess] Queue._after_fork()
  Reading from webcam.
  Width: 640 Height: 480
  Traceback (most recent call last):
    File &quot;testRTSP_try.py&quot;, line 52, in &lt;module&gt;
      frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
  cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
  
  [INFO/MainProcess] process shutting down
  </code></pre>
  <p>Some more information:</p>
  <ol>
  <li>Camera footage is from raspberry pi</li>
  <li>RTSP stream created via:
  <code>raspivid -o - -t 0 -rot 180 -w 640 -h 480 -fps 25 -b 2000000 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:&lt;port&gt;/stream}' :demux=h264</code></li>
  <li>RTSP stream monitored via windows vlc</li>
  </ol>
  <p>I took a different approach by using motion instead see <a href="https://www.instructables.com/id/How-to-Make-Raspberry-Pi-Webcam-Server-and-Stream-/" rel="nofollow noreferrer">How to Make Raspberry Pi Webcam Server and Stream Live Video || Motion + Webcam + Raspberry Pi</a></p>
  <p>This will setup a http stream instead of a rtsp!</p>