title: Opencv2: Python: cv2.VideoWriter
body: <p>Why does the following code not save the video?
  Also is it mandatory that the frame rate of the webcam matches exactly with the <code>VideoWriter</code> frame size?</p>
  <pre><code>import numpy as np
  import cv2
  import time
  
  def videoaufzeichnung(video_wdth, video_hight, video_fps, seconds):
      cap = cv2.VideoCapture(6)
      cap.set(3, video_wdth) # wdth
      cap.set(4, video_hight) #hight 
      cap.set(5, video_fps) #hight 
      
      # Define the codec and create VideoWriter object
      fps = cap.get(5)
      fourcc = cv2.VideoWriter_fourcc(*'XVID')
      out = cv2.VideoWriter('output.avi', fourcc, video_fps, (video_wdth, video_hight))
      #out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640, 480))
      
      start = time.time()
      zeitdauer = 0
      while(zeitdauer &lt; seconds):
          end = time.time()
          zeitdauer = end - start
          ret, frame = cap.read()
          if ret == True:
              frame = cv2.flip(frame, 180)
              # write the flipped frame
              out.write(frame)
      
              cv2.imshow('frame', frame)
              if cv2.waitKey(1) &amp; 0xFF == ord('q'):
                  break
          else:
              break
      
      # Release everything if job is finished
      cap.release()
      out.release()
      cv2.destroyAllWindows()
  
  videoaufzeichnung.videoaufzeichnung(1024, 720, 10, 30)
  </code></pre>