Video to numpy array

Hi. Can someone please tell me how I can convert the video I have uploaded through file_uploader into NumPy array so that I can further process the video. I don’t understand how to deal with buffer or byte objects. Looking forward to your replies. Thanks in advance.

[EDIT] I want to run the following code with getting any errors:

video_file = st.file_uploader("Upload video",type=['mp4']
import imageio
video = imageio.mimread(video_file)

Hi @Sharan19 -

After you use the file_uploader widget, you will have a BytesIO buffer. To get the data from it, you need to read the buffer as shown here:

Thank you for the reply. I already tried this. This works for images but when I do the same for videos, I get a empty numpy array each time I convert bytes to numpy.