I'm trying to display a video from some arrays in an notebook in jupyter-lab. The arrays are produced at runtime. What method to display the images can deliver a (relatively) high framerate? Using matplotlib and imshow is a bit slow. The pictures are around 1.8 megapixel large. Above some very small example to visualize what I want to achieve.
while(True): #should run at least 30 times per second
array=get_image() #returns RGBA numpy array
show_frame(array) #function I search for
The fastest way (to be used for debug purpose for instance) is to use
matplotlib inline
and the matplotlibanimation
package. Something like this worked for meThe video will be reproduced in a loop with a specified framerate (in the code above I set the interval to 50 ms, i.e., 20 fps).
Please note that this is a quick workaround and that
IPython.display
has aVideo
package (you can find the documentation here) that allows you to reproduce a video from file or from an URL (e.g., from YouTube). So you might also consider storing your data locally and leverage the built-in Jupyter video player.