0

Im build an API that generates a video from a NumPy array.

from skimage import img_as_ubyte
import imageio

 imageio.mimsave('temp/{}.mp4'.format(id), [img_as_ubyte(frame) for frame in predictions], fps=fps)

however, I need to send this video as a Flask response:

send_file('temp/{}.mp4'.format(id),attachment_filename='{}.mp4'.format(id))

The only way I could find to do this is by saving it in a temp folder and then loading back... The video is very short, is there any way I could do this without saving it ??

  • 1
    From the docs, [flask.send_file](https://tedboy.github.io/flask/generated/flask.send_file.html#flask-send-file), the API will take a file object. Its not clear from the documentation whether a `io.BytesIO()` object will do, but worth a try. – tdelaney Oct 21 '22 at 04:25

0 Answers0