Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

speed up loading of animated gif kivy

Is there a way to speed how fast kivy will load an animated gif? Does kivy have any methods built in such as compression or other options? What I'm doing is using the animated gif as a background for the home screen of my app. It is the matrix, which has about 30 different frames to create the desired affect.. With 30 frames I'm not expecting this to be super fast, but 5-10 seconds for a single aniamted gif to load seems a bit much.

like image 298
Pythonista Avatar asked Nov 19 '15 02:11

Pythonista


People also ask

How do you make a GIF less laggy?

Change the speed of GIF (WebP, MNG) animation If you want to change animation speed proportionally to the current animation, use "% of current speed" from the drop down. Entering 200% will make animation run 2x faster, 50% will cause it to slow down 2x. Slowing down a GIF too much may cause it to lose smoothness.

Why is my GIF lagging?

The main reason why your GIFs load so slowly is likely because you have too many frames in the GIF. Next time, delete one frame for every two that you use. Reddit user MichaelTunnell found that this method makes GIFs much faster and fixes the problems that can come from opening the GIF in different browsers.

How many FPS should a GIF be?

Standard GIFs run between 15 and 24 frames per second.


2 Answers

I believe this may help you, I had a series of png files that I wanted to animate into an explosion, and this was a game where the explosions were constant. Initially, every time the animation took place, the game stalled and stuttered horribly. This is what I did to get my game to run smoothly. I zipped the png files, and used the following code to preload them, which I placed in the __init__ method of the Screen widget that the images appeared on.

load_zipped_png_files = Image(
    source = 'explosion.zip', 
    anim_delay = 0,
    allow_stretch = True, 
    keep_ratio = False,
    keep_data = True)

I believe the keep_data option allows for the preloading of the images( into a cache I imagine ), which saves the program from having to reload them every time they are used.

Now it could be that I am mistaken about the role keep_data is playing here ( and if someone reading this knows better, please do correct me ), but zipping the files and using them in this way definitely made the animations acceptably smooth. You could test it with and without keep_data = True and figure it out yourself.

like image 56
Totem Avatar answered Sep 21 '22 01:09

Totem


For me it simply worked as i needed to gifs extension images:

Image(
source= 'image.gif', 
anim_delay= 0,
mipmap= True,
allow_stretch= True)

It was added mipmap, so that enhances the textures using OpenGL.

like image 22
João Luis Avatar answered Sep 21 '22 01:09

João Luis