title: Python + OpenCV + Base64: Issue with converting frame to base64
body: <p>I am trying to convert a video to frames and those frames to base64 strings. I am unable to do so and getting some exceptions. Below is my code:</p>
  <pre><code>import cv2
  import base64
  
  
  def footage_to_frame(video):
      vidcap = cv2.VideoCapture(video)
      success, frames = vidcap.read()
      if success:
          return frames
  
  
  def frame_to_base64(frames):
      with frames as frame:
          frame_b64 = base64.b64encode(frame.read())
      return frame_b64
  </code></pre>
  <p>The function calls to this method are:</p>
  <pre><code>frames = converter.footage_to_frame(&quot;/Users/myname/Desktop/video.mp4&quot;)
  converter.frame_to_base64(frames)
  </code></pre>
  <p>Below is the error I get in console:</p>
  <pre><code>File &quot;/Users/myname/Desktop/Test/src/service/converter.py&quot;, line 13, in frame_to_base64
      with frames as frame:
  AttributeError: __enter__
  </code></pre>