title: Stream an opencv video over RTSP
body: <p>Does anyone know a link where I can catch RTSP stream to test video capture with rtsp video source? I have tried it with usb cam and with webcam, but I want to test it with RTSP stream.</p>
  
  <p>Here is the source:</p>
  
  <pre><code>#include "opencv2/highgui/highgui.hpp"
  #include &lt;iostream&gt;
  
  using namespace cv;
  using namespace std;
  
  int main(int argc, char* argv[])
  {
      VideoCapture cap("rtsp:\\ANYTHING,PLEASE"); // open the video file for reading
  
      if ( !cap.isOpened() )  // if not success, exit program
      {
           cout &lt;&lt; "Cannot open the video file" &lt;&lt; endl;
           return -1;
      }
  
      //cap.set(CV_CAP_PROP_POS_MSEC, 300); //start the video at 300ms
  
      double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
  
       cout &lt;&lt; "Frame per seconds : " &lt;&lt; fps &lt;&lt; endl;
  
      namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
  
      while(1)
      {
          Mat frame;
  
          bool bSuccess = cap.read(frame); // read a new frame from video
  
           if (!bSuccess) //if not success, break loop
          {
                          cout &lt;&lt; "Cannot read the frame from video file" &lt;&lt; endl;
                         break;
          }
  
          imshow("MyVideo", frame); //show the frame in "MyVideo" window
  
          if(waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
         {
                  cout &lt;&lt; "esc key is pressed by user" &lt;&lt; endl; 
                  break; 
         }
      }
  
      return 0;
  
  } 
  </code></pre>