[SOLVED] Playing a movie displayable at multiple speeds (or framerates?)

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Semicolonkid
Regular
Posts: 51
Joined: Tue Feb 14, 2017 6:13 pm
Projects: Summoned
itch: semicolonkid
Contact:

[SOLVED] Playing a movie displayable at multiple speeds (or framerates?)

#1 Post by Semicolonkid »

Apologies in advance, because I get a little confused when it comes to framerates, refresh rates, and animation speeds.

Currently, I've got animations that rely on an image sequence with a delay between each image (or frame), and I'm able to adjust this delay to make the animation go slower or faster. It doesn't work perfectly, but in regards to slow/medium/fast, I don't need to add any additional frames or change anything for it to look good.

I was wondering if I could do the same thing with the Movie displayable instead. Movie files are smaller and sound like they offer better performance than playing an animation as an image sequence.

So, as a simplified example:

Code: Select all

image snowstorm_movie = Movie(play = "snowstorm.webm")

label start:

	show snowstorm_movie
	"Normal snowstorm clip playing at normal speed."
	
	show snowstorm_movie
	"Same thing, but now at a slower speed."
	
	show snowstorm_movie
	"Same thing, but very fast."
The Movie documentation states that the "fps" argument is ignored. I feel like adjusting the gl_framerate value is not really what I want.
Is there a way to play a fast version and a slow version of the movie clip by referencing the same file? As a bonus, would there be a way to gradually adjust this speed? (It's okay if not)

Do I instead need to make a fast and slow version of the animation at the same given framerate, essentially leading to three different video files being stored?

I couldn't find an answer for anything like this, but I thank you in advance if you've got any ideas.
Last edited by Semicolonkid on Sun Sep 04, 2022 5:49 pm, edited 1 time in total.
Image

User avatar
plastiekk
Regular
Posts: 112
Joined: Wed Sep 29, 2021 4:08 am
Contact:

Re: Playing a movie displayable at multiple speeds (or framerates?)

#2 Post by plastiekk »

Not too long ago I experimented with the same considerations and did not come to any useful result. My solution was to convert the images (animations) to .webp format, as it is a very good space-saving alternative to transparent .png images and is supported by renpy.
https://developers.google.com/speed/webp/docs/using

Hope this helps you.
Why on earth did I put the bread in the fridge?

User avatar
Semicolonkid
Regular
Posts: 51
Joined: Tue Feb 14, 2017 6:13 pm
Projects: Summoned
itch: semicolonkid
Contact:

Re: Playing a movie displayable at multiple speeds (or framerates?)

#3 Post by Semicolonkid »

plastiekk wrote: Sat Sep 03, 2022 9:45 am Not too long ago I experimented with the same considerations and did not come to any useful result. My solution was to convert the images (animations) to .webp format, as it is a very good space-saving alternative to transparent .png images and is supported by renpy.
https://developers.google.com/speed/webp/docs/using

Hope this helps you.
Yeah, I experimented for a while after asking this and decided to stick with image animations too.

Didn't know about the .webp format, so I'm reading up about that. Most my images are .jpgs (all the ones used in my animations are), and I'm hearing mixed results about .webp compared to .jpg.
However, it seems like with simpler cartoony images like I'm working with, .webp can get down to less than half the size of my .jpg's without losing any quality!

I'll look into this more. Thanks!
Image

User avatar
plastiekk
Regular
Posts: 112
Joined: Wed Sep 29, 2021 4:08 am
Contact:

Re: Playing a movie displayable at multiple speeds (or framerates?)

#4 Post by plastiekk »

Semicolonkid wrote: Sat Sep 03, 2022 11:06 am Yeah, I experimented for a while after asking this and decided to stick with image animations too.
I love the .webp format ^.^
By the way, some people complain that you can't audio-sync image animations. But this is in fact not true.

Here is a small example that lets our hero train (animation-loop) and while he hits the sandbag a sound is played. I don't have time to draw images but the code snippet should show how to do it.
(For people who are interested.)

Code: Select all

init python:
    def punch(trans,st,at):     # simple function to play a sound
            renpy.sound.stop    # mute other played sounds on channel "sound"
            renpy.sound.play("audio/punch.wav")
            return 
            
define wait_time = 0.1      # a timer

image training:             # the animation sequence

        "images/hero/training/0.webp
        wait_time           # wait 0.1 seconds
        "images/hero/training/1.webp
        wait_time            
        "images/hero/training/2.webp
        wait_time            
        "images/hero/training/3.webp
        wait_time            
        
        # This picture shows the hero hitting the sandbag.
        "images/hero/training/4.webp
        
        
        function punch          # plays the punch sound while showing image 4.webp
        linear .05 yzoom 1.01   # a transition to zoom a little 
        linear .02 yzoom 1.0    
        wait_time -0.07      # we used .07 seconds for the yzoom that's why we decrement the timer here
        
        
        # shows the same sequence backwards
        "images/hero/training/3.webp
        wait_time            
        "images/hero/training/2.webp
        wait_time            
        "images/hero/training/1.webp
        wait_time
        repeat           # and done is our image "fake movie" loop.

############        
label start:
    "Let's train!"
    show training
    "Phew, my hand hurts!"
    return
    
    
Why on earth did I put the bread in the fridge?

User avatar
Semicolonkid
Regular
Posts: 51
Joined: Tue Feb 14, 2017 6:13 pm
Projects: Summoned
itch: semicolonkid
Contact:

Re: Playing a movie displayable at multiple speeds (or framerates?)

#5 Post by Semicolonkid »

plastiekk wrote: Sun Sep 04, 2022 11:22 am Here is a small example that lets our hero train (animation-loop) and while he hits the sandbag a sound is played. I don't have time to draw images but the code snippet should show how to do it.
Very cool! I've heard about playing sounds within animation loops, but haven't gotten around to it yet. I'll bear this in mind, thanks!
Image

User avatar
Andredron
Miko-Class Veteran
Posts: 726
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: Playing a movie displayable at multiple speeds (or framerates?)

#6 Post by Andredron »

Semicolonkid wrote: Sun Aug 28, 2022 9:13 pm Apologies in advance, because I get a little confused when it comes to framerates, refresh rates, and animation speeds.

Currently, I've got animations that rely on an image sequence with a delay between each image (or frame), and I'm able to adjust this delay to make the animation go slower or faster. It doesn't work perfectly, but in regards to slow/medium/fast, I don't need to add any additional frames or change anything for it to look good.

I was wondering if I could do the same thing with the Movie displayable instead. Movie files are smaller and sound like they offer better performance than playing an animation as an image sequence.

So, as a simplified example:

Code: Select all

image snowstorm_movie = Movie(play = "snowstorm.webm")

label start:

	show snowstorm_movie
	"Normal snowstorm clip playing at normal speed."
	
	show snowstorm_movie
	"Same thing, but now at a slower speed."
	
	show snowstorm_movie
	"Same thing, but very fast."
The Movie documentation states that the "fps" argument is ignored. I feel like adjusting the gl_framerate value is not really what I want.
Is there a way to play a fast version and a slow version of the movie clip by referencing the same file? As a bonus, would there be a way to gradually adjust this speed? (It's okay if not)

Do I instead need to make a fast and slow version of the animation at the same given framerate, essentially leading to three different video files being stored?

I couldn't find an answer for anything like this, but I thank you in advance if you've got any ideas.
Python is not friendly with video files, it’s easier for you to split the video frame by frame, and write animations as a separate picture

As an example of what I do in my spare time

eyes_blink.rpy

Code: Select all

init:
    image mor01: 
        "p01_8"
        pause 3.2
        "p01_6"
        pause 0.1
        "p01_7"
        pause 0.1
        repeat
        
    image mor02: 
        "p02_8"
        pause 3.2
        "p02_1"
        pause 0.1
        "p02_7"
        pause 0.1
        repeat
        #And further in a similar vein
body.rpy

Code: Select all

init:
    image telo01:
        "t01"
        pause 0.1
        "t02"
        pause 0.1
        "t03"
        pause 0.1
        "t04"
        pause 0.1
        "t05"
        pause 0.1
        "t06"
        pause 0.1

        #And further in a similar vein
mouth.rpy

Code: Select all

image rot_28:
        "t155_6"
        pause 0.5
        "t155_7"
        pause 0.1
        "t155_8"
        pause 0.1
        "t155_7"
        pause 0.1
        "t155_8"
        pause 0.1
        
        #And further in a similar vein
script.rpy

Code: Select all

label start:
    $ renpy.movie_cutscene('ep01.webm')
     scene p01
     pause 0.1
     show rot_01

     voice "voice/001.ogg"
     nez "Good morning.{w=0.7}{nw}"
     show mor01

     $store._history = False

     nez "Good morning.{fast}"

     $store._history = True
     
     scene body01
     pause 3.2
     scene p02
     show rot_02
     voice "voice/002.ogg"
     nez "Woke up?{w=0.5}{nw}"

     $store._history = False
     show mor02
     nez "Wake up?{fast}"
videos - https://vk.com/video189145553_456239692

in the original novel, everything inside is done frame by frame, in the form of paintings. And if you do the same on the renpai, then it will be possible to make an android version, and there is a switch port, pspVita, etc. just need to stock up on nerves

User avatar
Semicolonkid
Regular
Posts: 51
Joined: Tue Feb 14, 2017 6:13 pm
Projects: Summoned
itch: semicolonkid
Contact:

Re: Playing a movie displayable at multiple speeds (or framerates?)

#7 Post by Semicolonkid »

Andredron wrote: Sun Sep 04, 2022 1:57 pm Python is not friendly with video files, it’s easier for you to split the video frame by frame, and write animations as a separate picture
Yeah, I already have it split up into frames and defined as an image sequence; I tried combining said frames into a movie to see if that'd be cleaner (fewer files, smaller total size, less lines of code). But it seems like changing the speed dynamically might not be possible without rendering multiple video files at different fps, which kinda defeats the purpose when I can already change the speed as-is (though it doesn't work perfectly or consistently across different machines, which drives me crazy and indicates a fundamental lack of understanding of framerate on my part).

Anyway, this helps further validate that maybe I'm not missing out on some perfect movie displayable technique. Thanks so much!
Image

User avatar
Semicolonkid
Regular
Posts: 51
Joined: Tue Feb 14, 2017 6:13 pm
Projects: Summoned
itch: semicolonkid
Contact:

Re: [SOLVED] Playing a movie displayable at multiple speeds (or framerates?)

#8 Post by Semicolonkid »

I'm gonna mark the thread as solved even though a definitive answer didn't come up per se. Sounds like the answer is "no" or "not worth it," but of course if anyone else has anything to add, feel free. To those who answered, thanks again for your insight!
Image

User avatar
Andredron
Miko-Class Veteran
Posts: 726
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: [SOLVED] Playing a movie displayable at multiple speeds (or framerates?)

#9 Post by Andredron »

And what's stopping you in animation, in a pause, instead of a numerical value, use a variable, and there either through a function, or if you don't understand well, then manually write

image animac:
bmg01
pause 1.0*speed_my

And then through the button set the conditions for the variable

action SetVariable("speed_my", 1)
action SetVariable("speed_my", 2)
action SetVariable("speed_my", 4)

Here's a rough crutch for you, a parody, school days for the short story, at a speed 1x, 2x, 4x....

Post Reply

Who is online

Users browsing this forum: No registered users