How To Add A Video To My Game (Solved)

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
Shadow17
Newbie
Posts: 20
Joined: Sat Dec 05, 2020 2:18 pm
Contact:

How To Add A Video To My Game (Solved)

#1 Post by Shadow17 »

Okay so I'm just starting out with my first game and before I do anything with Characters, backgrounds and images I want to add a video to my game.
Like before the menu pops up I want to add a unskippable 5 second video. I have the video an MOV form. I was told that I could change it if need be, but I'm confused on where to start or how to code it right. Cause every website I check on how to add a video it's either out of date or I do as the youtube video says and get an error.

What is the right and simple way to add a video to my video game
and can I add a video as my menu background and loop it?

Someone please help been at this for 2 days.
Last edited by Shadow17 on Sun Feb 21, 2021 2:44 pm, edited 1 time in total.

Dr_arell
Regular
Posts: 70
Joined: Sun Feb 23, 2020 11:24 pm
Deviantart: DarellArt
Contact:

Re: How To Add A Video To My Game

#2 Post by Dr_arell »

im a newbie as well, so this will be pretty much useless

you should start with the splashcreen, naming a label splashscreen will run that code before the menu, respecting to the video i remember hearing renpy supports only a couple of formats

this is my personal splashcreen, it has audio, skippable pauses and images, take that as example

Code: Select all

label splashscreen:

        scene black
        with Pause(1)
        # play music "audio/intro.mp3"
        show splash_screen with dissolve
        with Pause(2)
        scene black with dissolve
        with Pause(1)
        stop music
        play music "audio/intro 2.mp3"
        $ renpy.pause
        show splash_screen_2_image  with dissolve
        with Pause(1.5)
        stop music
        scene black with dissolve
        with Pause(1)
        show warning with dissolve
        with Pause(5)
        scene black with dissolve
        with Pause(1)
        return
        
for the animated menu background it can be done for sure, ive seen it before, one of the ways is creating an image made of more images with atl, and then just use it as background, there gotta be another way by placing directly the video, i dont suggest using my way if your video is long or complex

Code: Select all

image animation:
    "/images/Screen resources/Others/lab animation/1.png" with dissolve
    pause 0.4
    "/images/Screen resources/Others/lab animation/2.png" with dissolve
    pause 0.4
    "/images/Screen resources/Others/lab animation/3.png" with dissolve
    pause 0.4
    "/images/Screen resources/Others/lab animation/4.png" with dissolve
    pause 0.4

Code: Select all

        $ renpy.pause(5,hard=True)
that will prevent the screen from advancing 5 seconds

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: How To Add A Video To My Game

#3 Post by Per K Grok »

Shadow17 wrote: Sat Feb 20, 2021 9:31 pm Okay so I'm just starting out with my first game and before I do anything with Characters, backgrounds and images I want to add a video to my game.
Like before the menu pops up I want to add a unskippable 5 second video. I have the video an MOV form. I was told that I could change it if need be, but I'm confused on where to start or how to code it right. Cause every website I check on how to add a video it's either out of date or I do as the youtube video says and get an error.

What is the right and simple way to add a video to my video game
and can I add a video as my menu background and loop it?

Someone please help been at this for 2 days.
The first thing is that you need to have your video in a playable format. If you don't have that, nothing you do will work.

You have information on playable formats here
https://www.renpy.org/doc/html/movie.html

MOV is not mentioned so it is most probably not playable.

So convert your video to something on the list. Personally I use ogg or mkv.

There are different ways to play a video. One is define the video as an displayable. You can then include it in the game the same way you would with an image.

image mymovie= Movie(play="movie/mymovie.mkv")


Before you do anything more fancy, make sure you can run the video in the simplest possible way.

Code: Select all

image mymovie= Movie(play="movie/mymovie.mkv")

label start:
    show mymovie
    pause
If that works you can try the splashscreen.

Code: Select all

label splashscreen:

    show mymovie
    $ renpy.pause(5, hard=True)
    hide mymovie

    return
This will show the movie for 5 seconds then hide it and jump to start.

To have a displayable in a screen you use add

So if you go to screens.rpy, find screen main_menu and replace

add gui.main_menu_background

with

add "mymovie"


You will have a looping video as background to the main menu

Code: Select all

screen main_menu():

    ## This ensures that any other menu screen is replaced.
    tag menu

    style_prefix "main_menu"

    #add gui.main_menu_background
    add "mymovie"

User avatar
Shadow17
Newbie
Posts: 20
Joined: Sat Dec 05, 2020 2:18 pm
Contact:

Re: How To Add A Video To My Game

#4 Post by Shadow17 »

Per K Grok wrote: Sun Feb 21, 2021 3:22 am
Shadow17 wrote: Sat Feb 20, 2021 9:31 pm Okay so I'm just starting out with my first game and before I do anything with Characters, backgrounds and images I want to add a video to my game.
Like before the menu pops up I want to add a unskippable 5 second video. I have the video an MOV form. I was told that I could change it if need be, but I'm confused on where to start or how to code it right. Cause every website I check on how to add a video it's either out of date or I do as the youtube video says and get an error.

What is the right and simple way to add a video to my video game
and can I add a video as my menu background and loop it?

Someone please help been at this for 2 days.
The first thing is that you need to have your video in a playable format. If you don't have that, nothing you do will work.

You have information on playable formats here
https://www.renpy.org/doc/html/movie.html

MOV is not mentioned so it is most probably not playable.

So convert your video to something on the list. Personally I use ogg or mkv.

There are different ways to play a video. One is define the video as an displayable. You can then include it in the game the same way you would with an image.

image mymovie= Movie(play="movie/mymovie.mkv")


Before you do anything more fancy, make sure you can run the video in the simplest possible way.

Code: Select all

image mymovie= Movie(play="movie/mymovie.mkv")

label start:
    show mymovie
    pause
If that works you can try the splashscreen.

Code: Select all

label splashscreen:

    show mymovie
    $ renpy.pause(5, hard=True)
    hide mymovie

    return
This will show the movie for 5 seconds then hide it and jump to start.

To have a displayable in a screen you use add

So if you go to screens.rpy, find screen main_menu and replace

add gui.main_menu_background

with

add "mymovie"


You will have a looping video as background to the main menu

Code: Select all

screen main_menu():

    ## This ensures that any other menu screen is replaced.
    tag menu

    style_prefix "main_menu"

    #add gui.main_menu_background
    add "mymovie"
Okay so I did as you guys said and I'm NOT getting an error code anymore now when I launch the game it just gives me a black screen and "that's it" no sound to the video or words and I changed the changed the video format from ogv to ogg and mkv and still black screen unless I click the mouse then the game continues forwards to the game's menu.

But to me a black screen is something cause I was stuck on the error codes thing for days and couldn't for the life of me figure it out.
But anyways if you are wondering what kinda video it is?

It's just a video I made by using images that says WARNING BEFORE PLAYING THIS GAME blah blah blah I used my voice in the video so it's not copyrighted stuff or anything like it.

But how do I fix the black screen issue?
P.S thank you guys so much for helping me as well it really means a lot.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: How To Add A Video To My Game

#5 Post by rayminator »

try using webp format it a lot better

I have tried using mkv format and all I got was black screen when I have tried webp the video showed up

User avatar
Shadow17
Newbie
Posts: 20
Joined: Sat Dec 05, 2020 2:18 pm
Contact:

Re: How To Add A Video To My Game

#6 Post by Shadow17 »

rayminator wrote: Sun Feb 21, 2021 11:45 am try using webp format it a lot better

I have tried using mkv format and all I got was black screen when I have tried webp the video showed up
So is there certain was to change format I've just been going on the file and editing it's file name from Video.mkv to Video.webp or do I actually have to go on a website to convert it.

Or is there anyway I can send you guys the video and you guys can see if it runs on your game and if so tell me or show me what I'm doing wrong here
it's the most simplest thing yet I'm having so much trouble with it.

drKlauz
Veteran
Posts: 239
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: How To Add A Video To My Game

#7 Post by drKlauz »

webp is image format, you want webm.

Changing format is not just renaming mymovie.mov to mymovie.webm, recoding is necessary to change how pixels/audio stored internally.
To convert mov to webm you may use:
- ffmpeg - https://ffmpeg.org
- some online converter, for example (not tried myself) - https://www.freeconvert.com/mov-to-webm
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

User avatar
Shadow17
Newbie
Posts: 20
Joined: Sat Dec 05, 2020 2:18 pm
Contact:

Re: How To Add A Video To My Game

#8 Post by Shadow17 »

Shadow17 wrote: Sun Feb 21, 2021 12:03 pm
rayminator wrote: Sun Feb 21, 2021 11:45 am try using webp format it a lot better

I have tried using mkv format and all I got was black screen when I have tried webp the video showed up
So is there certain was to change format I've just been going on the file and editing it's file name from Video.mkv to Video.webp or do I actually have to go on a website to convert it.

Or is there anyway I can send you guys the video and you guys can see if it runs on your game and if so tell me or show me what I'm doing wrong here
it's the most simplest thing yet I'm having so much trouble with it.
hey thank you so much it works a bit blocky so I'm gonna try to turn down the resolution and hopefully that helps
thank you all who've helped :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]