Ren'Py is capable of using FFmpeg (included) to play movies using the video codecs:
and the following audio codecs:
inside the following container formats:
(Note that using some of these formats may require patent licenses. When in doubt, and especially for commercial games, we recommend using VP9, VP8, or Theora; Opus or Vorbis; and WebM, Matroska, or Ogg.)
Movies can be displayed fullscreen or in a displayable. Fullscreen movies are more efficient.
Ren'Py's movie decoder does not support movies with alpha channels, but the
side_mask parameter of the Movie()
displayable can be used for that
purpose. Here is an example of hhow to use ffmpeg to create a webm file with
a side-by-side mask from a mov file with an alpha channel.
ffmpeg -i original.mov -filter:v alphaextract mask.mov
ffmpeg -i original.mov -i mask.mov -filter_complex "hstack" -codec:v vp8 -crf 10 output.webm
Movies are not supported on the Web platform.
The easiest and most efficient way to display a movie fullscreen is
to use the renpy.movie_cutscene()
function. This function displays the
movie fullscreen until it either ends, or the player clicks to dismiss
it.
$ renpy.movie_cutscene("On_Your_Mark.webm")
On mobile platforms, such as Android and iOS, hardware video decoding is
used when config.hw_video
is changed to True. This can be faster, but the list of
supported movie formats depends on the
platform. See for instance
Android's supported media formats.
A quick way to test if your videos are supported is to copy them to your target device and play them with its default video player.
The Movie displayable can be used to display a movie anywhere Ren'Py can show a displayable. For example, a movie can be displayed as the background of a menu screen, or as a background.
The Movie displayable can also be used to define a movie sprite, which is a sprite that is backed by two movies. The primary movie provides the color of the sprite. A second movie, the mask movie, provides the alpha channel, with white being full opacity and black being full transparency.
Movies played by the Movie displayable loop automatically.
Here's an example of defining a movie sprite:
image eileen movie = Movie(play="eileen_movie.webm", side_mask=True)
The movie sprite can be shown using the show statement, which automatically starts the movie playing. It will be automatically stopped when the displayable is hidden.
show eileen movie
e "I'm feeling quite animated today."
hide eileen
e "But there's no point on wasting energy when I'm not around."
A Movie displayable can also be used as part of a screen, provided it is created during the init phase (for example, as part of an image statement.)
image main_menu = Movie(play="main_menu.ogv")
screen main_menu:
add "main_menu"
textbutton "Start" action Start() xalign 0.5 yalign 0.5
Multiple movie displayables or sprites can be displayed on the screen at once, subject to system performance, and provided all share the same framerate. The behavior of Ren'Py when displaying movies with different framerates is undefined, but will likely include a significant amount of frame drop.
renpy.
movie_cutscene
(filename, delay=None, loops=0, stop_music=True) linkThis displays a movie cutscene for the specified number of seconds. The user can click to interrupt the cutscene. Overlays and Underlays are disabled for the duration of the cutscene.
Returns True if the movie was terminated by the user, or False if the given delay elapsed uninterrupted.
Movie
(fps=24, size=None, channel=u'movie', play=None, mask=None, mask_channel=None, image=None, play_callback=None, side_mask=False, loop=True, start_image=None, **properties) linkThis is a displayable that shows the current movie.
config.single_movie_channel
and config.auto_movie_channel
.If true, this tells Ren'Py to use the side-by-side mask mode for the Movie. In this case, the movie is divided in half. The left half is used for color information, while the right half is used for alpha information. The width of the displayable is half the width of the movie file.
Where possible, side_mask should be used over mask as it has no chance of frames going out of sync.
If not None, a function that's used to start the movies playing. (This may do things like queue a transition between sprites, if desired.) It's called with the following arguments:
A movie object has the play parameter available as _play
,
while the channel
, loop
, mask
, and mask_channel
fields
correspond to the given parameters.
Generally, this will want to use renpy.music.play()
to start
the movie playing on the given channel, with synchro_start=True.
A minimal implementation is:
def play_callback(old, new):
renpy.music.play(new._play, channel=new.channel, loop=new.loop, synchro_start=True)
if new.mask:
renpy.music.play(new.mask, channel=new.mask_channel, loop=new.loop, synchro_start=True)