title: how take rtsp in server and convert to mp4
body: <p>I would like to take the video stream (rtsp) from the DVR and send it to the server then convert it to .mp4 and send it to an application I'm developing.
  how can I do all this?</p>
  
  <p>possibly with python, do you have any suggestions?</p>
  
  <p>Thanks in advance</p>
  
  <pre><code>    1 import numpy as np
      2 import cv2
      3 
      4 cap = cv2.VideoCapture('rtsp link')
      5 
      6 # Define the codec and create VideoWriter object
      7 fourcc = cv2.VideoWriter_fourcc(*'XVID')
      8 out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
      9 
     10 while(cap.isOpened()):
     11     ret, frame = cap.read()
     12     if ret==True:
     13         frame = cv2.flip(frame,0)
     14 
     15         # write the flipped frame
     16         out.write(frame)
     17 
     18         cv2.imshow('frame',frame)
     19         if cv2.waitKey(1) &amp; 0xFF == ord('q'):
     20             break
     21     else:
     22         break
     23 
     24 # Release everything if job is finished
     25 cap.release()
     26 out.release()
     27 cv2.destroyAllWindows()
  </code></pre>
  
  <p>i am trying to use opencv:</p>
  
  <ul>
  <li><p>save the file,</p></li>
  <li><p>when I open the output file, it does not open (0byte)</p></li>
  </ul>