title: Python function to read video and convert to frames
body: <p>I want to convert my input video to a set of frames. I have read the post on 
  <a href="https://stackoverflow.com/questions/33311153/python-extracting-and-saving-video-frames">Python - Extracting and Saving Video Frames</a>. </p>
  
  <p>But I would like to have a function where I can insert the video as the parameter, not the location of the video file. </p>
  
  <p>In the VideoCapture function below, it takes in the location of the video file.</p>
  
  <pre><code>import cv2
  def vidtoframes(videoFile):
   vidcap = cv2.VideoCapture(videoFile)
   success,image = vidcap.read()
   count = 0
  
   while success:
    cv2.imwrite("frame%d.jpg" % count, image) # save frame as JPEG file      
    success,image = vidcap.read()
    print('Read a new frame: ', success)
    count += 1
  </code></pre>
  
  <p>But is there a function or way to pass a video to the method and convert it to array of frames without saving anything onto the disk.</p>