Ren'Py REN´PY MOVIES LAGGING

Jul 28, 2017
66
13
163
Okey, so Im aspiring to make a VN with TONS of animations displayed as videos, but, some time ago while checking the progress of the game, I noticed the movies where lagging sometimes, when I rollback to check the animation again it doesnt lag most of the time on the second roll, but It really bothers me it doesnt work as intended since I already took so much time rendering everything at 1080p 60fps with a shitty laptop that barely delivers a 3sec long render video in about 6-8 mins. (multiply this by at LEAST 10 animations for scene)

Im by no means an expert on ren´py, but I tried to learn what I needed for the job (using mostly screens for interactable events with the enviroment or characters, and movies .webm format VP9 codec), and that lagging it´s the only problem I haven´t manage to solve. So, please, if anybody could provide some insight in the matter I would appreciate it.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
12,777
21,017
1,026
[...] that lagging it´s the only problem I haven´t manage to solve. So, please, if anybody could provide some insight in the matter I would appreciate it.
Since it works when you rollback, you already have the reason of your problem right in front of you ; your movies are too big and the lag you're seeing is the time needed by Ren'py to load them.
 
  • Like
Reactions: RegularD.Generate
Jul 28, 2017
66
13
163
Since it works when you rollback, you already have the reason of your problem right in front of you ; your movies are too big and the lag you're seeing is the time needed by Ren'py to load them.
OHhh I see, mmm, then is there anything at all I could do(except reducing the quality of the videos) to improve this?
I really dont know much about the gpu usage on renpy but, any way to make it more dependant on it?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
12,777
21,017
1,026
I really dont know much about the gpu usage on renpy but, any way to make it more dependant on it?
As I said, the problem come from the time needed to load the movie. The way Ren'py play is not the reason of the lag ; that would induce stuttering, not a lag before the movie start. You can possibly reduce a little (really a little) this time by putting the movies in a RPA archive, it can possibly make you benefit from the drive and/or OS caches, but that's all you can do without touching to the movie itself.

This being said, if you look at the other threads related to Ren'py movies, you would find good advice. By example how to reduce the file size without really reducing its quality, or how to make the lag less obvious by using the image argument of .
 
  • Like
Reactions: RegularD.Generate
Jul 28, 2017
66
13
163
As I said, the problem come from the time needed to load the movie. The way Ren'py play is not the reason of the lag ; that would induce stuttering, not a lag before the movie start. You can possibly reduce a little (really a little) this time by putting the movies in a RPA archive, it can possibly make you benefit from the drive and/or OS caches, but that's all you can do without touching to the movie itself.

This being said, if you look at the other threads related to Ren'py movies, you would find good advice. By example how to reduce the file size without really reducing its quality, or how to make the lag less obvious by using the image argument of .
Alright I understand.
Out of curiosity, I´ve read that UNITY could do for a very good VN platform, would you happend to know if it´s true and if i could get more benefits from it? would you recomend it ?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
12,777
21,017
1,026
Out of curiosity, I´ve read that UNITY could do for a very good VN platform, would you happend to know if it´s true and if i could get more benefits from it?
You can do good VN with Unity, and you could avoid your problem by using it, yes.


would you recomend it ?
It totally depend. Do you know how to code a cache mechanism in C# ?

What you've to understand is that using Unity and using Ren'py are two totally different things. Ren'py will do all the basic moves, and more, for you. This while by using Unity you'll have write the code by yourself. You can rely on templates and some frameworks, but none will be as generic as Ren'py is. Therefore either you'll still have to code some addition or change part of the code of the template, or you'll have to deal with what you have and not what you wanted.
Said otherwise, Ren'py coding requirement starts at 0, while Unity expect you to have a minimal knowledge if you want to achieve something, and an advanced knowledge if you want to achieve something effectively good.
 
Jul 28, 2017
66
13
163
Alright I understand.
Out of curiosity, I´ve read that UNITY could do for a very good VN plataform, would you happend to know if it´s true and if i could get more benefits from it? would you recomend it ?
You can do good VN with Unity, and you could avoid your problem by using it, yes.




It totally depend. Do you know how to code a cache mechanism in C# ?

What you've to understand is that using Unity and using Ren'py are two totally different things. Ren'py will do all the basic moves, and more, for you. This while by using Unity you'll have write the code by yourself. You can rely on templates and some frameworks, but none will be as generic as Ren'py is. Therefore either you'll still have to code some addition or change part of the code of the template, or you'll have to deal with what you have and not what you wanted.
Said otherwise, Ren'py coding requirement starts at 0, while Unity expect you to have a minimal knowledge if you want to achieve something, and an advanced knowledge if you want to achieve something effectively good.
Thanks for the insight!
 
Jul 28, 2017
66
13
163
Small update*
I tried this two commands and i belive they gave me some imrpovement, but still looking for more info.

define config.cache_surfaces = True

define config.image_cache_size_mb = 4000

For what I understood, basically RAM usage for images has been enabled up to 4gb.
 
Jul 28, 2017
66
13
163
Is there any way to preload all movies before the game starts?, or to add loading screens to preload the movies of a certain section of the game?
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
3,378
6,495
707
Is there any way to preload all movies before the game starts?, or to add loading screens to preload the movies of a certain section of the game?
Apart from Anne O'ymous's suggestions above, there is the "start_predict" function that can potentially be used to control the preload of Displayables.

Refer to this in the documentation.


The idea would be:
1. create a displayable for the movie ( )
2. in an appropriate place in your script (i.e. a few dialogue lines before the movie should display), call the "start_predict" for that displayable.
3. after you are past the movie, remove it from the prediction cache with "stop_predict"

However some caveats:
1. i've never tried this in my code, so it's just a concept you need to test yourself
2. the predict cache has a limited size and will already be occupied by images etc that the game has auto-predicted (and note that renpy might have ALREADY predicted your movie anyway) so there might be trouble fitting the movie data in the limited space.
3. you should also try transcoding / resizing / cropping the movie to smaller size/better codec/lower quality, this will always help with the problems you are seeing.
 
Jul 28, 2017
66
13
163
Small update*
I manage to reduce drastically the size of a movie animation from 632 kb to 147kb by re-compressing the file with Movavi Convert Video program, again same format .webm codec 9, while specifiying 1080p 60fps. There was a warning about lossing quality on the video, but after comparing with original I couldn´t saw any diference at all, so I assume the quality reduction was minimal.

It seems this really helped with the animation in game, so I´ll procced to do the same with all of them.
 
  • Like
Reactions: osanaiko

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,683
7,946
715
It's worth pointing out that 60fps may be overkill. If you dropped down to 30fps, you halve the bitrate required for the same quality. Most people won't notice the difference.
 
Jul 28, 2017
66
13
163
It's worth pointing out that 60fps may be overkill. If you dropped down to 30fps, you halve the bitrate required for the same quality. Most people won't notice the difference.
Yeah, I understand that but, the animations that I´m making are not, lets say "cutscenes", they´re kinda like "reactions" animations based on the interaction of the player with the diferent parts of the body of the npcs, so I wanted to make them feel like that, like if it is happening "in the moment". Maybe it´s a bit to much, but I wanna keep trying.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
12,777
21,017
1,026
Yeah, I understand that but, the animations that I´m making are not, lets say "cutscenes", they´re kinda like "reactions" animations based on [...]
Of course, the higher the frame rate is, the better will be the result, but the majority of movies that you see in theaters, then later on TV, are still in 24fps, and you can't say that they aren't some serious works.
It's uncertain what the effective frame rate that eyes/mind can see is ; it was expected to be 25fps, but nowadays it's less certain. But anyway more than 30fps is to consider as luxury. It will be smoother, but most people will only see the difference if the movies are put side to side.
To this have to be added that computer screens not being CRT anymore, and so having less concern regarding afterglow, most of them have a default frame rate at 50Hz. What mean that most of your players will anyway not see more than 50fps.
 
  • Like
Reactions: RegularD.Generate
Jul 28, 2017
66
13
163
Small Update*
I´ve found another piece of code that seems to be helping with the animation loading, the "renpy.cache_pin(*your movie*)" and "renpy.cache_unpin(*your movie*)". They seems to function together like a preload of the animations, kinda like a loading screen, allowing the game to prepare for the animations loading them before and storing them in your RAM. For obvious reasons this is a RAM heavy operation, but seems to be working.
 
  • Like
Reactions: osanaiko