'extract thumbnail from online video link

I am building a website, and I am trying to extract one image from a video directly using the link provide by a user.

The things is that all need to be done in memory: download the video in memory (using requests for example), extract an image and I upload it on my aws bucket

I have searched for a solution and found cv2. I was able locally to extract one image using:

vcap = cv2.VideoCapture(path_to_vid)
res, thumb_buf = cv2.imencode('.png', im_ar)
bt = thumb_buf.tostring()

The issue is, after some research, reading and decoding from bytes or content of response is not supported, so I am back to the beginning.

Ideally I wanted something like this:

r = requests.get(url)
vcap = cv2.VideoCapture(io.BytesIO(r.content))
res, thumb_buf = cv2.imencode('.png', im_ar)
bt = thumb_buf.tostring()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source