Tool Ren'Py Video Fast Forward for Renpy

Mr_Algorithm

New Member
Nov 5, 2017
3
13
Problem
I've struggled a lot with Renpy's lack of ability to navigate videos. When you click on the video, the game skips the entirety of it. This combined with my absolute lack of patience, caused me to skip most videos in Renpy based games and miss a lot of good parts.



Solution
It was really a huge hurdle to go through since there is no proper documentation and I wasn't able to find anyone providing something useful for this specific problem. But, I managed to develop a makeshift tool in python for implementing video fast forward (it is more like a jump forward rather than a fast forward) ability to renpy games. This method currently requires the game to be using "renpy.movie_cutscene()" for playing the videos. But if there are differences and you are familiar with python, you should be able to adjust it.



How to Use
Keep in mind that this tool is not optimized & prettified in terms of code and since it is a python script that you have to run the generate some files, it is not very end user friendly.


I've attached the scripts as a zip file. I've also created an example project that can be downloaded via these links:
- -


Overview
First script is called "get_durations.py" to be used for obtaining video duration file for the ".webm" videos in a folder. Code can be easily modified for other video extensions. It requires moviepy library which can be installed via "pip install moviepy". If you don't prefer to deal with the library requirements and if you have small number of videos, you can check "mdurations.txt" and manually create one for yourself in a similar format.

Second script is called "generate_code.py", this script uses the duration file generated by the previous script to generate a file called "moviepart.rpy". This is the file that allows the game to play the videos in parts and allows the player to skip forward. One large benefit of this method is the file being completely non-disruptive to the main game code. You can just delete the "moviepart.rpy" and your game will return back to normal. The portions that you would like to divide the video can be easily modified in the script by changing "divider" variable.

I divided it into two scripts since first script tends to take much longer compared to the second script. It was much easier to run first one only once then experiment with the second one using the file generated. I've tested the tool in a few games and it works well. But, there might still be bugs.


Steps

  1. Move all webm videos into "videos" folder under "game" folder.
  2. Move the "get_durations.py" into the folder you have videos and run it.
  3. Move the generated "mdurations.txt" file to "game" folder.
  4. Move the "generate_codes.py" into the "game" folder and run it.
  5. Enjoy the fast/jump forward functionality for videos in your game!



Big Disclaimer: At the time I developed this tool, I personally wasn't able to find any proper solutions for this in the internet. It is likely that there will be or maybe already are alternative and/or better solutions out there that I'm not aware of. This post is just for desire to share the knowledge/experience and maybe make a few peoples work easier at the same time. If I made your work easier or your game more enjoyable, please feel free to .



Technical Babblings for Anyone Interested
I've experimented with several methods. Other than obvious lack of functionality in renpy for video navigation, some of the biggest problems that I've faced:

  • Renpy doesn't allow you to dynamically define images within renpy game runtime. Therefore you can't get very creative with this method, unfortunately.
  • Renpy loads the videos in different times depending on the system speed and video resolution. If your method of approach is to divide the video into small parts and play one after another, this problem messes up your approach so bad. If you don't consider the load time, flickers happen between the parts. Solving this by trying to load one video just before hiding the previous one also messes up sound and causes video stutter since you can't perfectly predict the switch time.

Is my solution perfect? Ofc not. Script code is obviously a mess (I don't have much free time for this). There are some points that I observed might be problematic in some rare cases. There are also more functionality/QoL that can be quickly added if I had more free time. I probably won't spend any more time on this but feel free to share any ideas and to use the methods in the tool or modify the tool for your purposes.
 
  • Heart
Reactions: Studio Kami