Dizty dev seeks animation assist...

Nottravis

Sci-fi Smutress
Donor
Game Developer
Jun 3, 2017
5,132
27,267
I've had a look (honest!) but can't seem to find a pre-existing answer to this one...

So, I've had small animations in the second chapter of my game but they were quite simple and I was able to get them in the old Renpy machine by simply adding them the frames as scenes and sticking a 0.1 delay in between them all. So far, so simple and it worked nicely enough.

For Chapter Three I've pushed the boat out a bit and have three animations of several hundred frames each. (my patrons bought me a new graphics card so...seemed only right to use it!). OK, all very nice, but why am I telling you all this? :)

Because it's dawned on me (yes, only just now...) that given I usually have around 500-600 images per monthly release, I'm going to be doubling my file size this month if I do it the way I usually do. Now, this doesn't seem like that should be the case and I suspect that there's a more efficient way of getting these animations in that doesn't involve whomping up the download size by an extra 400-500mb.

So...my question is, how do I drop animations into renpy in the smallest Mb size possible without losing graphical quality? Any answers gratefully accepted. Thanks :)
 

monkeyposter_7

Thirsty for my Guest
Game Developer
Nov 23, 2018
330
1,181
Well, best for not losing quality is doing a image sequence.
and maybe adding a "animation.rpy" script for only animations and writing a code for the animations like this for example

You don't have permission to view the spoiler content. Log in or register now.

and then in your main script u call this animation with:
scene aniamtionblowjob1
pause

Others might have better suggestions though :)
 

Nottravis

Sci-fi Smutress
Donor
Game Developer
Jun 3, 2017
5,132
27,267
Well, best for not losing quality is doing a image sequence.
and maybe adding a "animation.rpy" script for only animations and writing a code for the animations like this for example

You don't have permission to view the spoiler content. Log in or register now.

and then in your main script u call this animation with:
scene aniamtionblowjob1
pause

Others might have better suggestions though :)
Thanks :)
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,496
7,082
So...my question is, how do I drop animations into renpy in the smallest Mb size possible without losing graphical quality? Any answers gratefully accepted. Thanks :)
While sticking with long sequences of images will arguably give you better quality, during an animation, your viewers don't have a lot of opportunity to stare at each individual frame looking for wonky pixels, etc.

The alternate approach is to convert your image sequence into a video, and then have Ren'py just play the video. This typically can give you significantly smaller total size, since the video compression takes advantage of pixels that are the same in consecutive frames.

One tool available that will do this is ffmpeg. It's a command line tool, which may not be the most convenient for point-and-clickers, but it's very controllable, and will easily produce the type of video that Ren'py can happily play. (There may be others - this just happens to be one that I'm comfortable with, and thus use a lot.)
 

Nottravis

Sci-fi Smutress
Donor
Game Developer
Jun 3, 2017
5,132
27,267
While sticking with long sequences of images will arguably give you better quality, during an animation, your viewers don't have a lot of opportunity to stare at each individual frame looking for wonky pixels, etc.

The alternate approach is to convert your image sequence into a video, and then have Ren'py just play the video. This typically can give you significantly smaller total size, since the video compression takes advantage of pixels that are the same in consecutive frames.

One tool available that will do this is ffmpeg. It's a command line tool, which may not be the most convenient for point-and-clickers, but it's very controllable, and will easily produce the type of video that Ren'py can happily play. (There may be others - this just happens to be one that I'm comfortable with, and thus use a lot.)
Thank you -so- much! Appreciated! :)
 
  • Like
Reactions: Namco15

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,278
22,428
I use to turn my animations into videos. It simple, free, doesnt need to be installed, can export as webm (and other formats too of course) and the best thing is it recognizes image sequences, so you only need to open the first image and VD2 imports the rest.
 

Nottravis

Sci-fi Smutress
Donor
Game Developer
Jun 3, 2017
5,132
27,267
I use to turn my animations into videos. It simple, free, doesnt need to be installed, can export as webm (and other formats too of course) and the best thing is it recognizes image sequences, so you only need to open the first image and VD2 imports the rest.
Thank you! You guys are so helpful.

I really appreciate it :)
 
  • Like
Reactions: Namco15

polywog

Forum Fanatic
May 19, 2017
4,062
6,264
While sticking with long sequences of images will arguably give you better quality, during an animation, your viewers don't have a lot of opportunity to stare at each individual frame looking for wonky pixels, etc.

The alternate approach is to convert your image sequence into a video, and then have Ren'py just play the video. This typically can give you significantly smaller total size, since the video compression takes advantage of pixels that are the same in consecutive frames.

One tool available that will do this is ffmpeg. It's a command line tool, which may not be the most convenient for point-and-clickers, but it's very controllable, and will easily produce the type of video that Ren'py can happily play. (There may be others - this just happens to be one that I'm comfortable with, and thus use a lot.)
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,384
15,292
While sticking with long sequences of images will arguably give you better quality, [...]
It can also lead to some freeze if the interval between each frame is too small, and/or the size of the images too big, and/or the computer of the player too old.


The alternate approach is to convert your image sequence into a video, and then have Ren'py just play the video.
Just ensure that you choose a format that Ren'py ; but it's not like you are really limited, so it's definitively the best option for long animations. This while the full Ren'py approach stay the best for small ones, since it offer you a better control over it, with the help of the , and if needed a containing screen.
 

Nottravis

Sci-fi Smutress
Donor
Game Developer
Jun 3, 2017
5,132
27,267
It can also lead to some freeze if the interval between each frame is too small, and/or the size of the images too big, and/or the computer of the player too old.




Just ensure that you choose a format that Ren'py ; but it's not like you are really limited, so it's definitively the best option for long animations. This while the full Ren'py approach stay the best for small ones, since it offer you a better control over it, with the help of the , and if needed a containing screen.
Thanks - I'm playing around with various options at the mo to try and get the balance right between size and quality.

*can't believe she didn't think about this before...*
 
  • Like
Reactions: Namco15

Joraell

Betrayed
Donor
Game Developer
Jul 4, 2017
2,474
8,780
@Nottravis
Definitelly use webm format. Renpy works nice with it. And making webm from files is really simple just by CMd code no programs needed .-)

ffmpeg -f image2 -framerate 20 -i Bethany%03d.png -minrate 7M -vf fps BethanyS02_boobsgrow.webm
FFmpeg is here:
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,496
7,082
I use to turn my animations into videos.
Used VirtualDub years ago - completely forgot that it will support image sequences. Thanks for refreshing my memory. It is, indeed, a nice package.

Thanks - I'm playing around with various options at the mo to try and get the balance right between size and quality
You may already know this, but in the comand line @Joraell gave you:
Code:
ffmpeg -f image2 -framerate 20 -i Bethany%03d.png -minrate 7M -vf fps BethanyS02_boobsgrow.webm
quality is controlled via the "7M" parameter - this particularly command line says "encode at a minimum of 7 megabits per second" I tend to use "-b:v 2M" instead, which says "try to encode as close to 2 megabits per second as possible" but either approach is fine. Essentially making this number smaller reduces the output size at the cost of some quality, and increasing it increases the output size, with better quality.

Note that one feature of ffmpeg that I frequently use when dealing with image sequences is that you can prepare a text file giving it the file inputs instead of relying on their naming to establish the image sequence. If all you're doing is rendering an image sequence straight thru, this doesn't really buy you anything. But suppose that you have an "in and out" animation - depending on exactly what you're trying to achieve, you could potentially only create the image sequence for the "in" half and then create the "out" sequence by using the same frames in reverse. To do this, create the input text file as:
Code:
file 'in00.jpg'
file 'in01.jpg'
file 'in02.jpg'
... (omitted)
file 'in09.jpg'
file 'in10.jpg'
file 'in09.jpg'
... (omitted)
file 'in02.jpg'
file 'in01.jpg'
and feed it to ffmpeg using a command line like:
Code:
ffmpeg -r 24 -f concat -i input.txt -c:v libvpx -b:v 2M animation.webm
("-f concat" explicitly tells ffmpeg that it's doing an image sequence concatenation, and "-i input.txt" gives it the text file as input)

This creates a 20-frame animation where the second half is the first half in reverse. You could also use this technique if you had an animation in two parts, and wanted the first part to repeat, say, 3 times, followed by the second part repeating twice. Saves you rendering frames multiple times.

Not that you couldn't do this with something like VirtualDub by copying files into the correct names, etc., but (at least for me) this approach is a lot easier.
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,496
7,082
One other point - when you use a movie file in a "scene" statement, there is the possibility of a very brief delay while the movie is being loaded, which can result in a "grey screen" being flashed at your user, since the old background may get cleared before the movie is completely ready to play.

In older versions of Ren'py, I would get around that by doing:
Code:
image the_movie_definition = Movie(play='path_to_the_movie_file', ...other options...)

   ....

    scene first_frame_of_video
    show the_movie_definition
where first_frame_of_video was the image that was, well, the first frame of the video. That way, the first frame might show "not moving" for a tiny fraction of a second, but then it would get covered by the movie, and the effect would be pretty seamless.

Starting with Ren'py 7.2.0, PyTom has added a "start_image" option to the that will do this for you automatically, so you can now just do:
Code:
image the_movie_definition = Movie(play='path_to_the_movie_file', start_frame='first_frame_of_video',  ...other options...)

   ....

    scene the_movie_definition
and not have any "flash of grey."

(of course, you don't have to define the movie as an image - you can put the Movie() definition right on the "scene" line if you wish - this is just my own style.)
 

Nottravis

Sci-fi Smutress
Donor
Game Developer
Jun 3, 2017
5,132
27,267
One other point - when you use a movie file in a "scene" statement, there is the possibility of a very brief delay while the movie is being loaded, which can result in a "grey screen" being flashed at your user, since the old background may get cleared before the movie is completely ready to play.

In older versions of Ren'py, I would get around that by doing:
Code:
image the_movie_definition = Movie(play='path_to_the_movie_file', ...other options...)

   ....

    scene first_frame_of_video
    show the_movie_definition
where first_frame_of_video was the image that was, well, the first frame of the video. That way, the first frame might show "not moving" for a tiny fraction of a second, but then it would get covered by the movie, and the effect would be pretty seamless.

Starting with Ren'py 7.2.0, PyTom has added a "start_image" option to the that will do this for you automatically, so you can now just do:
Code:
image the_movie_definition = Movie(play='path_to_the_movie_file', start_frame='first_frame_of_video',  ...other options...)

   ....

    scene the_movie_definition
and not have any "flash of grey."

(of course, you don't have to define the movie as an image - you can put the Movie() definition right on the "scene" line if you wish - this is just my own style.)
Thank you soooo much for taking the time for such a comprehensive and detailed reply. I'm most grateful. :)
 

Nottravis

Sci-fi Smutress
Donor
Game Developer
Jun 3, 2017
5,132
27,267
@Nottravis
Definitelly use webm format. Renpy works nice with it. And making webm from files is really simple just by CMd code no programs needed .-)

ffmpeg -f image2 -framerate 20 -i Bethany%03d.png -minrate 7M -vf fps BethanyS02_boobsgrow.webm
FFmpeg is here:
Thank you! :)
 
  • Like
Reactions: Namco15 and Joraell

polywog

Forum Fanatic
May 19, 2017
4,062
6,264
Definitelly use webm format
webm uses CPU while other video formats can be optimized for GPU (20x better performance)

sex has a lot of repetition.. ins and outs, ups and downs rather than playing a 1 minute video, you can randomize shorter clips to make it less monotonous faster/slower hard thrust etc. still one minute in total, but smaller total file size.
vid1, vid2, vid2, vid3, vid4, vid2, vid3 vid4, vid2. sequence of 10 second clips vs one 60 second video
renpy can also "loop" a short clip 2 or 3 times reducing the file size
mp4s can be sequenced without issues. webms choke sometimes and can give you flashing between videos
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,496
7,082
webm uses CPU while other video formats can be optimized for GPU (20x better performance)
webm is just a container format. It has little to do with whether the video can be hardware accelerated or not - that depends on the codec that you use to encode the video stream itself.

The two most common codecs used with the webm container are VP8 and VP9.




Essentially, there are hardware implementations of both, both in the desktop and mobile environment, but VP9 is supported more than VP8 when it comes to hardware acceleration. Of course, even if your chipset supports hardware acceleration, whether or not it actually gets used depends on how your video playback software is set up. Ren'py uses libav for playback. One presumes that the version of this library that PyTom uses was compiled for hardware acceleration support, but I don't know that for sure.

Realistically, "hardware acceleration or not" is unlikely to be a decision point for the vast majority of people using video in games - the software implementations are perfectly adequate. Oh, if you were trying to play a lot of videos simultaneously, or do "video textures" in Unity inside a 3D game, you might run into problems, but for "just show a single video on a screen in a 2D game such as Ren'py" I seriously doubt you'd ever see an issue.

In addition, VP8 and VP9 are royalty-free, whereas most of the other that can be hardware-accelerated have patent entanglements.

MPEG-1 patents have expired, but this is a VERY old format, and doesn't perform near as well as the others.


Theora is not patent-entangled, but is considered an obsolete format by many. (Android refused to add native support for it, for example.)

Finally, H.264, which is one of the (patent-entangled) codecs that has pretty much ubiquitous hardware acceleration support, is substantially worse than VP9 in terms of its ability to compress video, so file sizes tend to be significantly larger for equivalent quality, or have more artifacts at equivalent file sizes. Not surprising, since the the format is something like 15 years old at this point. Its primary replacement, H.265, is only slowly being adopted, again because of patent licensing issues. The VP9 compression performance was one of the reasons that back in 2015. (Youtube internally encodes videos in a number of different codecs for playback, since it wants to be able to play back on essentially any device, but VP9 seems to be their "preferred" codec.) That last link includes an embedded example showing the improved result of using VP9 over H.264 at equivalent bandwidths.

OK, probably far more than anybody wanted to know, and straying a bit from the question in the OP, but there you are...
 
  • Like
Reactions: Porcus Dev

polywog

Forum Fanatic
May 19, 2017
4,062
6,264
webm is just a container format. It has little to do with whether the video can be hardware accelerated or not - that depends on the codec that you use to encode the video stream itself.

The two most common codecs used with the webm container are VP8 and VP9.




Essentially, there are hardware implementations of both, both in the desktop and mobile environment, but VP9 is supported more than VP8 when it comes to hardware acceleration. Of course, even if your chipset supports hardware acceleration, whether or not it actually gets used depends on how your video playback software is set up. Ren'py uses libav for playback. One presumes that the version of this library that PyTom uses was compiled for hardware acceleration support, but I don't know that for sure.

Realistically, "hardware acceleration or not" is unlikely to be a decision point for the vast majority of people using video in games - the software implementations are perfectly adequate. Oh, if you were trying to play a lot of videos simultaneously, or do "video textures" in Unity inside a 3D game, you might run into problems, but for "just show a single video on a screen in a 2D game such as Ren'py" I seriously doubt you'd ever see an issue.

In addition, VP8 and VP9 are royalty-free, whereas most of the other that can be hardware-accelerated have patent entanglements.

MPEG-1 patents have expired, but this is a VERY old format, and doesn't perform near as well as the others.


Theora is not patent-entangled, but is considered an obsolete format by many. (Android refused to add native support for it, for example.)

Finally, H.264, which is one of the (patent-entangled) codecs that has pretty much ubiquitous hardware acceleration support, is substantially worse than VP9 in terms of its ability to compress video, so file sizes tend to be significantly larger for equivalent quality, or have more artifacts at equivalent file sizes. Not surprising, since the the format is something like 15 years old at this point. Its primary replacement, H.265, is only slowly being adopted, again because of patent licensing issues. The VP9 compression performance was one of the reasons that back in 2015. (Youtube internally encodes videos in a number of different codecs for playback, since it wants to be able to play back on essentially any device, but VP9 seems to be their "preferred" codec.) That last link includes an embedded example showing the improved result of using VP9 over H.264 at equivalent bandwidths.

OK, probably far more than anybody wanted to know, and straying a bit from the question in the OP, but there you are...
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,496
7,082
An interesting read, but
  1. It's eight years old (August 2010), only a couple of months after WEBM+VP8 was launched.
  2. It focuses on playback in browsers, which had only just barely begun to add support.
  3. "The initial developer preview releases of browsers supporting WebM are not yet fully optimized and therefore have a higher computational footprint for screen rendering than we expect for the general releases" As such, you have to take the relative numbers with a significant grain of salt for 2019.
Note, I'm in no way trying to argue that software decoding isn't going to take more CPU than hardware-accelerated decoding. Of course it is. The real issue is whether that's the primary decision point for someone building a video, or whether issues of patent entanglement or compression ratio or something else are more significant.

But I did LOVE the line:
However, one suspects that you could buy a Tastee Freez in Hades before WebM will play on the walled garden of Apple iDevices
And he's correct - 8+ years later, iOS still hasn't added it.

(For others reading the thread, that doesn't mean that Ren'py-iOS won't play WebM videos - it will. What he's talking about is either native support, or support within Apple Safari. Since Ren'py brings along its own video playback software, this isn't an issue.)