FBpyGIF
FBpyGIF copied to clipboard
Pre-load GIF images?
I was planning to use FBpyGIF in my project to show GIF looping animations based on events. Thanks to #12 it now perfectly works, however the load time is quite long for some GIFs: (on a Raspberry Pi 3)
- 5 secs to load the program & play 1 GIF
- 4 secs to play this same GIF in a playlist (after program is loaded)
I can't wait so long as GIF are illustrating the events in real time.
I see in the README.md you have planned to:
- [ ] Background loading of next animation file to reduce loading delay between them
Would you consider the possibility to load/prepare the whole playlist in memory and allow showing the right one based on events/signals/other?
I've looked into main.py and have the feeling that fb.ready_fb() could be what I'm looking for.
I'm ready to write some Python code if you would provide such library.
Many thanks in advance for your help.
👍 like to see a "net-socket" or the like, to have external control while running.
my usecase would be somehow: i could show certain images on external events (from my homeautomation) for certain time, than come back to random loop again ..
like once described here: https://github.com/chidea/FBpyGIF/issues/6
@ozett fyi I run a similar project (voice assistant for home automation) and I ended up using gifview from gifsicle in X. I'm waiting this enhancement to go back to the framebuffer world.
Sorry for late reply. I was away from my home.
Loading uncompressed frames onto memory requires huge size of it.
You can simply calculate the size of it by bpp*width*height*frames/8 = x (bytes).
That 4 seconds are simply because CPU needs long I/O time to load up image from SD card into memory, frame by frame with uncompressing calculations. After playing of each image, it just removes image from memory to gather free memory for next image. The thing here is that Raspberry has too small RAM, weak CPU and deadly slow I/O time than real PC. Furthermore, I don't have time to invent another faster algorithm.
If you need to use it even though with this obstacles, what you can consider is these two options.
- Preview flag shows uncompressed frame before uncompressing next frame. This'll slowly draw first iteration of loop and normally after. This is almost the same as how every modern web browsers does internally.
- Manual use of
ready_giffunction. This function loads up frames onto memory, into a single python list to be returned. You can put this list later intogif_loopfunction with an event to control the loop of gif play.ready_fbfunction is for setting up framebuffer in first load up your program. Calling this can cause kernel to reset display and framebuffer driver.