Ren'Py How to make a movie with different POVs

korukoru

New Member
Aug 13, 2020
11
2
Hi guys, I'll try to explain the best I can. What I'm trying to do is to make a video with different POVs that can be changed by pressing a button. By changing POVs I mean that I switch between different videos. I got that to work nicely ( it works nice functionally, code wise it might be a bit scuffed).
The last thing that I want to do is to make it so that if I watch the first video for let's say 5 seconds and then I press the "switch POV" button to get me to the next POV, I want that second video(POV) to start at the second 5 so it would look like I'm actually changing POVs and not just playing another video. Attached below is my current code


Python:
init python:
    def define_videos(variable_prefix, folder, video_prefix, count, loop=False, group_name="pov_group"):
        
        for i in range(1, count + 1):
            video_id = f"{variable_prefix}{i}"
            video_path = f"{folder}/{video_prefix}{i}.webm"
            renpy.image(video_id, Movie(play=video_path, loop=loop, group=group_name))

    define_videos("IntroVideo", "Images/IntroScenes", "IntroVideo", 20, loop=True)

screen switch_pov_videos():
    textbutton "Switch POV" action [Function(switch_video)]

init python:
    global current_video
    current_video = "IntroVideo6"

    video_sequence = {
        "IntroVideo6": "IntroVideo7",
        "IntroVideo7": "IntroVideo8",
        "IntroVideo8": "IntroVideo9",
        "IntroVideo9": "IntroVideo6",
    }

    def switch_video():
        global current_video
        next_video = video_sequence[current_video]

        renpy.show(next_video)
        renpy.hide(current_video)
        current_video = next_video
Please let me know if there is anything that you didn't understand from my question or what I would like to achieve. Also if you see any room for improvement for my current code or if you know any easier way to achieve what I already did please let me know :)
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,548
4,633
I think you are saying that you want the video to always play to the end of the playtime (i.e. 5 seconds). Then it should check if a keypress/button click has occurred, and if so, switch to the selected new video, or else repeat the current video again. Is that correct?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,966
16,215
The last thing that I want to do is to make it so that if I watch the first video for let's say 5 seconds and then I press the "switch POV" button to get me to the next POV, I want that second video(POV) to start at the second 5 so it would look like I'm actually changing POVs and not just playing another video. Attached below is my current code
This isn't possible. There's currently no way to starts a video, or audio since they share the same functions, at a given point ; they'll always be played from the starts.

And there isn't really a trick to counter this. renpy.music.play() have a "synchro_start" argument that permit to starts all audios/videos at the same time, in order for them to be synchronized, but it isn't possible to then only show one, and even less to latter switch from one to another.

The only possible way to goes around that limitation would be to split the movie in small parts, and switch the point of view at the end of one of those parts.
 

peterppp

Active Member
Mar 5, 2020
762
1,348
This isn't possible. There's currently no way to starts a video, or audio since they share the same functions, at a given point ; they'll always be played from the starts.

And there isn't really a trick to counter this. renpy.music.play() have a "synchro_start" argument that permit to starts all audios/videos at the same time, in order for them to be synchronized, but it isn't possible to then only show one, and even less to latter switch from one to another.

The only possible way to goes around that limitation would be to split the movie in small parts, and switch the point of view at the end of one of those parts.
would it be possible to use something like livecomposite (or something similar if that isn't supported anymore) to show several videos, showing the selected video fullsize or near to, and the others one pixel big or whatever, and dynamically change the size of the videos with conditionswitches?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,966
16,215
would it be possible to use something like livecomposite (or something similar if that isn't supported anymore) to show several videos, showing the selected video fullsize or near to, and the others one pixel big or whatever, and dynamically change the size of the videos with conditionswitches?
The idea is interesting, but it wouldn't works. would play all the movies simultaneously, but then you've now way to change their size. could have been a way to do this, and even in fact to not need Composite in the first place, but it start the video right from the starts each time the condition change.

This being said, I forgot that and therefore renpy.play can get parameters for . But the issue here is that it don't works like show/renpy.show, but like . Therefore it will display the movie in full screen and don't really respect its ratio.
I also don't know if it accept "expression", and therefore if the starting point can be dynamically defined. Yet, the strange way OP is doing this (through python code) mean that it would be just half an issue here ; the way the string defining the movie to play have been generated doesn't matter.



Edit:
Okay, forget about this. I did a quick test and, while play stop the movie where asked to, it systematically starts it from the very first second, what defeat the interest here.
 

korukoru

New Member
Aug 13, 2020
11
2
What I was thinking of, and It might be what peterp is trying to say, is to play all the videos at the same time and only one of them to be on top while all the others are running in the background, and all I do by pressing the SwitchPOV button is to put the next video on top.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,966
16,215
What I was thinking of, and It might be what peterp is trying to say, is to play all the videos at the same time and only one of them to be on top while all the others are running in the background, and all I do by pressing the SwitchPOV button is to put the next video on top.
What isn't possible the way you decided to play the videos.

I guess that something like should perhaps works:
/!\ I haven't tested the code, it's an idea, not something necessarily working /!\
Python:
label whatever:
    call screen myMoviePlayer( start="POV", movies={ "POV" : "movies01.webm", "top": "movies02.webm", "side": "movies03.webm" } )
    [...]

screen myMoviePlayer( start, movies):

    default current = start

    for pov in movies:
        add movies[pov] as pov:
            if pov != current:
                xpos renpy.screen_width

    vbox:
        for pov in movies:
            textbutton pov:
                action [ SetField( current, "xpos", renpy.screen_width ), SetField( pos, "xpos", 0 ), SetScreenVariable( current, pov ) ]
        textbutton "Close":
            action Return()
The principle is to display all the movies outside of the screen, and then move them on the screen when selected. Using the possibility to name a widget to access the properties ; not sure that "xpos" is correct here.

It's not impossible that Ren'Py screen refresh would be enough to move the correct add. In which case this would be enough:
Python:
screen myMoviePlayer( start, movies):

    default current = start

    for pov in movies:
        add movies[pov] as pov:
            if pov != current:
                xpos renpy.screen_width

    vbox:
        for pov in movies:
            textbutton pov:
                action SetScreenVariable( current, pov )
        textbutton "Close":
            action Return()
But whatever the method used, it mean that all the movies will be loaded in memory simultaneously. They need to be small enough since, unless it's made through a version 8.x, Ren'Py will only have access to 4GB of RAM.
It will also means that all the movies will be played simultaneously, what can significantly raise the CPU load and, like Ren'Py is made with Python, will possibly lead to a global slowdown of the game when the movies are played.
 
  • Like
Reactions: peterppp