title: How to convert a video (on disk) to a rtsp stream
body: <p>I have a video file on my local disk and i want to create an rtsp stream from it, which i am going to use in one of my project. One way is to create a rtsp stream from vlc but i want to do it with code (python would be better).
  I have tried opencv's VideoWritter like this</p>
  
  <pre><code>import cv2
  
  _dir = "/path/to/video/file.mp4"
  cap = cv2.VideoCapture(_dir)
  
  framerate = 25.0
  out = cv2.VideoWriter(
      "appsrc ! videoconvert ! x264enc noise-reduction=10000 speed-preset=ultrafast tune=zerolatency ! rtph264pay config-interval=1 pt=96 ! tcpserversink host=127.0.0.1 port=5000 sync=false",
      0,
      framerate,
      (1920, 1080),
  )
  
  
  counter = 0
  while cap.isOpened():
      ret, frame = cap.read()
      if ret:
          out.write(frame)
          print(f"Read {counter} frames",sep='',end="\r",flush=True)
          counter += 1
          if cv2.waitKey(1) &amp; 0xFF == ord("q"):
              break
      else:
          break
  
  cap.release()
  out.release()
  </code></pre>
  
  <p>But when i stream it on vlc like this</p>
  
  <blockquote>
    <p>vlc -v rtsp://127.0.0.1:5000
    I am getting </p>
  </blockquote>
  
  <pre><code>[00007fbb307a3e18] access_realrtsp access error: cannot connect to 127.0.0.1:5000
  [00007fbb2c189f08] core input error: open of `rtsp://127.0.0.1:5000' failed
  [00007fbb307a4278] live555 demux error: Failed to connect with rtsp://127.0.0.1:5000
  </code></pre>
  
  <p>Gstreamer is another option but as i have never used it, so would be nice if someone points me in the right direction. </p>