0

I am trying to extract frames from gifs/videos that have been uploaded to the server through a post request. I have the code working to grab the file:

my_file = request.files['file']

however if that file is a gif or video I'm kind of stuck. The cv2 and Image package both require that the video or gif is stored in a file and you input the filename to grab the file, but that's not going to be possible as I'm not trying to store user data. So what I want to do is uppload it to a tmp folder, extract the frames then put it back, how could I go about doing that?

Matt S
  • 23
  • 1
  • 6
  • This question is current closed as a duplicate of a deleted question, so I cannot post a proper answer, but according to https://stackoverflow.com/questions/11552926/how-to-read-raw-png-from-an-array-in-python-opencv it seems that at least cv2 can be made to read an image directly from an in-memory stream by first converting it into a numpy array. – Ilmari Karonen Apr 08 '18 at 19:29

1 Answers1

4
my_file.save("path/to/your/tmp/folder")

saves the uploaded file there.

darksky
  • 1,955
  • 16
  • 28