Ren'Py Best way to play movie in ren'py

XartusStudio

Enchanting lewd
Game Developer
Jul 1, 2021
95
113
Hey all!

In video I mean mp4 or other video format. What is the best way to launch them in code?
 

Lou111

Active Member
Jun 2, 2018
543
686
Hey all!

In video I mean mp4 or other video format. What is the best way to launch them in code?
Firstly, mp4 videos aren't compatible with Ren'Py Thanks 79flavors !
You'd be doing yourself a favor by reading at least twice.
The "best" way is too broad, the "easiest" way...
put this somewhere:
Python:
init:
    image myvideo = Movie(size=(400,560), channel="mychannel", play="video/sexy video.webm", loop=True)
when you want to show the video:
Python:
label start:
    show myvideo
when showing the video it can take positional arguments:
Python:
label start:
   show myvideo at truecenter

The "best" way depends on what your doing. It could be just a pop up video, an interactive scene, part of a screen, or God knows what else.
My advice, if you don't have a preference just use webm (common and compatible) videos and keep them as close to 24 FPS as possible.
 
Last edited:

XartusStudio

Enchanting lewd
Game Developer
Jul 1, 2021
95
113
Firstly, mp4 videos aren't compatible with Ren'Py
You'd be doing yourself a favor by reading at least twice.
The "best" way is too broad, the "easiest" way...
put this somewhere:
Python:
init:
    image myvideo = Movie(size=(400,560), channel="mychannel", play="video/sexy video.webm", loop=True)
when you want to show the video:
Python:
label start:
    show myvideo
when showing the video it can take positional arguments:
Python:
label start:
   show myvideo at truecenter

The "best" way depends on what your doing. It could be just a pop up video, an interactive scene, part of a screen, or God knows what else.
My advice, if you don't have a preference just use webm (common and compatible) videos and keep them as close to 24 FPS as possible.
Okey, I get it. Tell me, is it better to record the video in mp4 and convert to webm, or to record in webm right away?
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
Firstly, mp4 videos aren't compatible with Ren'Py
You'd be doing yourself a favor by reading at least twice.

Just a tiny correction. .mp4 files are just fine in RenPy. However some codecs are not.
The dead giveaway (in the documentation you yourself linked) is the line "Ren'Py is capable of using FFmpeg (included) to play movies using the video codecs : MPEG-4 part 2 (including Xvid and DivX)". Note the reference to MPEG-4 (i.e. mp4).

.mp4, like .webm or .mkv is just a container or wrapper. It's a bit like a .zip file, in so much as it just contains other "tracks".

Codecs are effectively formats of music or audio tracks. A bit like the difference between Microsoft Word and Google Docs or LibreOffice's Writer or even Adobe PDFs. They all create rich text documents, but how they are internally formatted differs. A video file using VP9 or VP8 will likely come within a .webm wrapper. A video file using h264 will likely come within a .mp4 or .mkv wrapper. VP9, VP8, h264 (MPEG4), etc are all codecs.

In theory, you could have a .mp4 file that contained VP9 encoded video in the same way you could have a .webm file that contained h264 tracks.

In short, "most" .mp4 video files will be fine - but if they don't work, it's because they're encoded with incompatible codecs.

Edit: btw, .webm (or at least VP9/VP8) is also a lossy format too. You can set options to make it lossless, at which point you lose all the size/file compression advantages that using a modern codec like VP9 usually brings (albeit at a higher CPU cost).
 
Last edited:

Lou111

Active Member
Jun 2, 2018
543
686
Okey, I get it. Tell me, is it better to record the video in mp4 and convert to webm, or to record in webm right away?
Oof. This is more about video editing than coding. I'm no specialist in this but here's what I think I know:

.mp4 is a "lossy" format. This means every time you convert it, change it, or whatever, it loses a bit of quality.
If you're going to be editing the video more than once you should keep it in a "lossless" format like .avi
So the best answer I think would be to record it in webm straight away
If you plan on making changes to it, record it in .avi first, keep it as a backup, then convert the final product to .webm

Edit:
After reading the post from 79flavors, if you're familiar with making sure you have compatible codecs (which I am not), you could just use .mp4
If you're like me and use videos from other sources, the .mp4 codecs are usually incompatible from my experience. How difficult it is to work around that is beyond me.
 
Last edited: