title: VideoWriter does not save the video correctly
body: <p>I'm trying to use <code>VideoWriter</code> to save the retrieved frames as video file but it seems it does not work. I have checked the while loop and print the output is working. I don't know why the output of the video is only O kb.</p>
  <pre><code> def detect_video(self, path, output_path):
      
      # Set output video writer with codec
          fourcc = cv2.VideoWriter_fourcc(*'mp4v')
          out = cv2.VideoWriter(output_path, fourcc, 25.0, (1920, 1080))
          # Read the video
          vidcap = cv2.VideoCapture(path)
          frame_read, image = vidcap.read()
          count = 0
          # Iterate over frames and pass each for prediction
          while frame_read:
              # Perform object detection and add to output file
              output_file = self.detect(image)
              #print(output_file)
              # Write frame with predictions to video
              out.write(output_file)
              # Read next frame
              frame_read, image = vidcap.read()
              count += 1
              #print(count)
          # Release video file when we're ready
          out.release()
  </code></pre>