Playing High Quality Movie

AlphaBubble

Newbie
Dec 29, 2017
52
23
Hello everyone,
I am trying to play two movies in renpy. Those Movies are very short(1.: about 0.4s, 2.: about 0,8s) and have a framerate of 30(the first one) and 50(the second one) frames.
I did it like this first:
Code:
$ renpy.movie_cutscene("crash1.mp4")
show 13
"FUUUUUUUUUCK!!!!"
$ renpy.movie_cutscene("crash2.mp4")
doesn't work. Renpy doesn't want to play the movies, just skips them.
Tried it with .webm and .ogv... worked, but frames are skipped and everything looks extremely awful, animation is laggy.
Then I tried this:
Code:
image Crash1 = Movie(play="crash1.mp4")
image Crash2 = Movie(play="crash2.mp4")
show Crash1
show 13
"FUUUUUUUUUCK!!!!"
show Crash2
doesn't work either, the same as before.
So I am just about to throw my computer out of the window... I already asked on but nobody knows anything either.
I am sitting here for 10 hours, searching the web, reading documentations, watching videos, reading posts here and on lemmasoft and it seems nobody has this problem expect me...
And yes, all the files are named correctly and I have turned sound in options.rpy on.
Sorry for my harsh language but I am quite pissed right now.
Anyways, I appreciate every help you guys hopefully can give me!
Thank you!
 

Palanto

Active Member
Game Developer
Oct 4, 2017
964
1,841
hmmmm
Could be a lot of things, my first guess is unsupported codec and my second would be that you didn't specify the framerate while defining them as movie displayables. Since the last two updates implemented some unusual behaviors in ren'py I would try setting it seperately (although it should be auto detected by ren'py, but who knows if there's a problem as well...)

about the webm and ogv thing, well that can happen with wrong or problematic codecs, to see which are supported you should check out the .

maybe try it like this:
Code:
image Crash1 = Movie(fps = 30, play="crash1.mp4")
image Crash2 = Movie(fps = 50, play="crash2.mp4")


label start:
    show Crash1
    show 13
    "FUUUUUUUUUCK!!!!"
    show Crash2
If that doesn't work either I can only imagine it's a codec problem. Some videos work great in VLC or other media players but total crap the hell out in ren'py.... but well it's a VN engine not a movie engine ;) You have to use those media files that are compatible with it :)
 
  • Like
Reactions: Nottravis

AlphaBubble

Newbie
Dec 29, 2017
52
23
maybe try it like this:
Code:
image Crash1 = Movie(fps = 30, play="crash1.mp4")
image Crash2 = Movie(fps = 50, play="crash2.mp4")


label start:
show Crash1
show 13
"FUUUUUUUUUCK!!!!"
show Crash2
If that doesn't work either I can only imagine it's a codec problem. Some videos work great in VLC or other media players but total crap the hell out in ren'py.... but well it's a VN engine not a movie engine ;) You have to use those media files that are compatible with it :)
Thanks for your reply!
I tried this now but it doesn't work either.
It turned out I was using H264 Codec which isn't supported. But I can't find a good video converter. Do you know one?
 

Palanto

Active Member
Game Developer
Oct 4, 2017
964
1,841
p.S.: I recommend VP8 or VP9 with mp3 audio in a .webm container (at least vp8 is pretty much compatible with most old android devices if you ever want to make it available there too... ;) )
 

AlphaBubble

Newbie
Dec 29, 2017
52
23
p.S.: I recommend VP8 or VP9 with mp3 audio in a .webm container (at least vp8 is pretty much compatible with most old android devices if you ever want to make it available there too... ;) )
Okay thank you very much for your help!
 

AlphaBubble

Newbie
Dec 29, 2017
52
23
p.S.: I recommend VP8 or VP9 with mp3 audio in a .webm container (at least vp8 is pretty much compatible with most old android devices if you ever want to make it available there too... ;) )
Yeah... I could need some advise ^^. I downloaded shotcut and imported the videos. I selected the webm preset and set quality to highest. The codec is libvpx. I exported the video but three frames are being skipped at the end. Do you know why?
 

AlphaBubble

Newbie
Dec 29, 2017
52
23
Here's a little update:
I tried different video editing softwares and converters but everytime I export to .webm with the right codec (vp8) the last few frames are missing. So I went on and tried .ogg. The movie is with the right quality just fine, but it doesn't work in renpy or is laggy/displays green error stripes. Of cource I used the right codec (thalea). I also tried .mp4 with xvid encoding but tis isn't even displayed. So I kinda gave up on movies. Now I am trying to do animazions with frames. I want to display 37 frames in 0.65 seconds which isn't possible because of the cache limit of renpy. So I reduced the amount of images to 10. I want 50 fps so 1/50 = 0.02s per image 0.02*37=0,75s original length. 0.75/10 =0.075s per image.
I implemented that an inage is shown for 0.075s but it seems that renpy isn't capable of doing this either. So my question is: Is there any way I can do fluid animations without movies or atl?
 

Epadder

Programmer
Game Developer
Oct 25, 2016
568
1,064
are the last frames just lost during conversion or just Ren'py doesn't display the last 3 frames?
Regardless if its 3 frames... couldn't you repeat the last frame of your actual animation 4 times so that it basically just cuts off the 3 'dummy' frames ?
 

Madeddy

Active Member
Dec 17, 2017
841
491
I think the issue could be related to the fact that you have very short video sequences and how you did the job. But thats guessing out of the belly.

Another reason could be found in the cutting you did and the GOP. Read up about it to understand what i am talking:
Means: If you cut after/before the wrong image some more get automatic dropped or the player can not show some of the frames. The solution would be "cut AND recoding" of the new sequence.

Also: I would advice to pick a target format(s) thats works well and some popular editing application and stay with it while trying to solve this. Jumping between all this adds more possible error sources and questions to the equation.
 

AlphaBubble

Newbie
Dec 29, 2017
52
23
Thanks to @f95zoneuser463 I've been able to convert the videos with ffmpeg to .webm using vp8 and vorbis. Anyways, the last few frames are missing again.
are the last frames just lost during conversion or just Ren'py doesn't display the last 3 frames?
Regardless if its 3 frames... couldn't you repeat the last frame of your actual animation 4 times so that it basically just cuts off the 3 'dummy' frames ?
The last frames are missing in the video player and in renpy. Yes I could do that but that would mean a big quality loss.
Another reason could be found in the cutting you did and the GOP. Read up about it to understand what i am talking:
Means: If you cut after/before the wrong image some more get automatic dropped or the player can not show some of the frames. The solution would be "cut AND recoding" of the new sequence.
Thank you, I will look over it!
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
If you can use Premiere, put your image series in it and generate an MP4, before you save the file, in preferences, there's a parameter where you can specify keyframes (default is 75 I think)... so, if you video have 50 frames for example, put this value at 25, this way Premiere will generate a keyframe in the beggining, in the middle and in the end (the end is the most important perhaps due to your problem); you can try too to set at 10 (every 10 frames Premiere put a keyframe).

Try this MP4 if works with renpy, if you have problems you can convert it using this online converter:
(choose your MP4 file, select video codec (VP8 or VP9, VP9 is better) and start conversion).

Good luck!
 

f95zoneuser463

Member
Game Developer
Aug 14, 2017
219
1,024
The source are two video in these formats:
You don't have permission to view the spoiler content. Log in or register now.

I was able to reproduce some playback-problems. I found that the pixelformat is one big problem and causes playback issues. (More info on at the bottom under Compatibility) By adding -pix_fmt yuv420p we can force the recommended 4:2:0 chroma subsampling. Usually converters try to keep the pixelformat of the source to avoid quality loss. That's bad in this case because it's bgr24. Not very well supported on 'consumer grade'-players.

VP9 encode command:
Code:
ffmpeg -i "crash2.avi" -c:v vp9 -crf 28 -b:v 0 -pix_fmt yuv420p -speed 1 -an "crash2.webm"
That should be better but it's not perfect yet. Unfortunately on the first playback Ren'Py still likes to 'swallow' the last frame(s), after that it plays fine. The file is okay. It's a player issue. VLC ends the playback to early too. Firefox, Chrome, Media Player Classic, MPV play it correct.

The .bat-files I send you are like little scripts. They contain the commands that you would enter on the console and comments. You can edit them in a texteditor. Since I'm lazy and don't wan't to remember all the ffmpeg-parameters I use them to automate things. (I have over 100 here to convert to various formats) You just need to make sure ffmpeg.exe can be called from the folder where you save the .bat-files. Saving both in the same folder will work. Drag & drop 'crash.avi' onto the .bat-file to start converting.

It looks like you want to create a shock-moment. Maybe you could simplify this into one longer video with a screenshot from Ren'Py inside the video. This will line will merge crash1.avi, a screenshot and crash2.avi into one video:
Code:
ffmpeg -r 50 -i "crash1.avi" -loop 1 -t 1 -i "screenshot.png" -i "crash2.avi" -c:v vp9 -crf 28 -b:v 0 -pix_fmt yuv420p -speed 1 -an -filter_complex "[0:v:0][1:v:0][2:v:0]concat=n=3:v=1[outv]" -map "[outv]" "merged.webm"
-t 1 will show the screenshot for 1 second

Other ideas:
  • add a silent audio-stream that is slightly longer than the video
  • add a screenshot of the last frame at the end and loop it for a short time
 
  • Like
Reactions: AlphaBubble

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
The source are two video in these formats:
You don't have permission to view the spoiler content. Log in or register now.
Fuck, this bitrate is insane x'D (is what you get with raw format without compression :p)

If you wanna try a converter program without needing to use command line, check this:
 

AlphaBubble

Newbie
Dec 29, 2017
52
23
The source are two video in these formats:
You don't have permission to view the spoiler content. Log in or register now.

I was able to reproduce some playback-problems. I found that the pixelformat is one big problem and causes playback issues. (More info on at the bottom under Compatibility) By adding -pix_fmt yuv420p we can force the recommended 4:2:0 chroma subsampling. Usually converters try to keep the pixelformat of the source to avoid quality loss. That's bad in this case because it's bgr24. Not very well supported on 'consumer grade'-players.

VP9 encode command:
Code:
ffmpeg -i "crash2.avi" -c:v vp9 -crf 28 -b:v 0 -pix_fmt yuv420p -speed 1 -an "crash2.webm"
That should be better but it's not perfect yet. Unfortunately on the first playback Ren'Py still likes to 'swallow' the last frame(s), after that it plays fine. The file is okay. It's a player issue. VLC ends the playback to early too. Firefox, Chrome, Media Player Classic, MPV play it correct.

The .bat-files I send you are like little scripts. They contain the commands that you would enter on the console and comments. You can edit them in a texteditor. Since I'm lazy and don't wan't to remember all the ffmpeg-parameters I use them to automate things. (I have over 100 here to convert to various formats) You just need to make sure ffmpeg.exe can be called from the folder where you save the .bat-files. Saving both in the same folder will work. Drag & drop 'crash.avi' onto the .bat-file to start converting.

It looks like you want to create a shock-moment. Maybe you could simplify this into one longer video with a screenshot from Ren'Py inside the video. This will line will merge crash1.avi, a screenshot and crash2.avi into one video:
Code:
ffmpeg -r 50 -i "crash1.avi" -loop 1 -t 1 -i "screenshot.png" -i "crash2.avi" -c:v vp9 -crf 28 -b:v 0 -pix_fmt yuv420p -speed 1 -an -filter_complex "[0:v:0][1:v:0][2:v:0]concat=n=3:v=1[outv]" -map "[outv]" "merged.webm"
-t 1 will show the screenshot for 1 second

Other ideas:
  • add a silent audio-stream that is slightly longer than the video
  • add a screenshot of the last frame at the end and loop it for a short time
So how do I know if it's bgr24 and I have to use-pix_fmt yuv420p?
I will try what you wrote, thank you.
Fuck, this bitrate is insane x'D (is what you get with raw format without compression :p)

If you wanna try a converter program without needing to use command line, check this:
Nah I'll stay with ffmpeg. It seems pretty powerful. Thank you anyways!
If you can use Premiere, put your image series in it and generate an MP4, before you save the file, in preferences, there's a parameter where you can specify keyframes (default is 75 I think)... so, if you video have 50 frames for example, put this value at 25, this way Premiere will generate a keyframe in the beggining, in the middle and in the end (the end is the most important perhaps due to your problem); you can try too to set at 10 (every 10 frames Premiere put a keyframe).

Try this MP4 if works with renpy, if you have problems you can convert it using this online converter:
(choose your MP4 file, select video codec (VP8 or VP9, VP9 is better) and start conversion).

Good luck!
That would be possible, but in premiere the minimum of time for one image is too high.
 

AlphaBubble

Newbie
Dec 29, 2017
52
23
It looks like you want to create a shock-moment. Maybe you could simplify this into one longer video with a screenshot from Ren'Py inside the video. This will line will merge crash1.avi, a screenshot and crash2.avi into one video:
Code:
ffmpeg -r 50 -i "crash1.avi" -loop 1 -t 1 -i "screenshot.png" -i "crash2.avi" -c:v vp9 -crf 28 -b:v 0 -pix_fmt yuv420p -speed 1 -an -filter_complex "[0:v:0][1:v:0][2:v:0]concat=n=3:v=1[outv]" -map "[outv]" "merged.webm"
I tried that one, but the first video is laggy. It's like it has only three frames. Also it's just like before, the last frames of both videos are missing.
The same goes for this:
Code:
ffmpeg -i "crash2.avi" -c:v vp9 -crf 28 -b:v 0 -pix_fmt yuv420p -speed 1 -an "crash2.webm"
So it seems it isn't because of the pixel format, isn't it?
 

f95zoneuser463

Member
Game Developer
Aug 14, 2017
219
1,024
So how do I know if it's bgr24 and I have to use-pix_fmt yuv420p?
  • ffprobe "crash1.avi" will show details including the pixelformat
  • in VLC Control + I -> Codec shows some infos but it's less detailed
YUV420 is standard for 'consumer grade' video, if anything fails, always use this. In theory every encoder should have some documentation somewhere about the supported pixelformats ... I've never looked this stuff up, could be somewhere on ... I don't know.
You should keep that -pix_fmt yuv420p when converting from a video with another pixelformat. The bitrate and filesize will be smaller because it needs less bytes per encoded pixel.

I tried that one, but the first video is laggy. It's like it has only three frames. Also it's just like before, the last frames of both videos are missing.
With quality-based encoding the bitrate was still very high. Try replacing -crf 28 -b:v 0 with -b:v 4M to use a lower fixed bitrate to see if the lag goes away. This will butcher the quality somewhat but it's a good test if the bitrate is to high.

I think I've made a mistake in the example with for merging the two videos+screenshot: the -r 50 at the beginning reads the first video as if it had 50fps, it should have been before the output file. As result the first video was played to fast and 1 frame was skipped at the end before the screenshot.
But due to this mistake I played with the framerates and found out that Ren'Py only seems to skip frames if the video is encoded in a high framerate. Since the video is very fast anyway maybe it's a good idea to slow it down slightly anyway.

I've slowed down the video to various frame-rates:
You don't have permission to view the spoiler content. Log in or register now.
It seems that RenPy starts skipping a frame at the end at around 30+ fps. It's hard to see with higher framerates. If I press F3 in RenPy to see the the FPS there is always a short dip when the video starts playing and then it's maxed at 60 fps. It's not like the PC isn't powerful enough.

Sending you a PM with my encoded test-videos.
 

AlphaBubble

Newbie
Dec 29, 2017
52
23
I've slowed down the video to various frame-rates:
Code:
REM merge two videos with 20 fps
ffmpeg -r 20 -i "crash1.avi" -r 20 -i "crash2.avi" -c:v vp9 -b:v 4M -pix_fmt yuv420p -speed 1 -an -filter_complex "[0:v:0][1:v:0]concat=n=2:v=1[outv]" -map "[outv]" "merged_2files_20fps.webm"
REM merge two videos read first as 20 fps, second as 25 fps, encode with 25 fps
ffmpeg -r 20 -i "crash1.avi" -r 25 -i "crash2.avi" -c:v vp9 -b:v 4M -pix_fmt yuv420p -speed 1 -an -filter_complex "[0:v:0][1:v:0]concat=n=2:v=1[outv]" -map "[outv]" -r 25 "merged_2files_mixed_25fps.webm"
REM merge two videos with 30 fps
ffmpeg -r 30 -i "crash1.avi" -r 30 -i "crash2.avi" -c:v vp9 -b:v 4M -pix_fmt yuv420p -speed 1 -an -filter_complex "[0:v:0][1:v:0]concat=n=2:v=1[outv]" -map "[outv]" "merged_2files_30fps.webm"

REM merge video+screenshot+video 20 / 30 fps
ffmpeg -r 20 -i "crash1.avi" -loop 1 -t 1 -i "screenshot.png" -r 20 -i "crash2.avi" -c:v vp9 -b:v 4M -pix_fmt yuv420p -speed 1 -an -filter_complex "[0:v:0][1:v:0][2:v:0]concat=n=3:v=1[outv]" -map "[outv]" -r 20 "merged_3files_20fps.webm"
ffmpeg -r 30 -i "crash1.avi" -loop 1 -t 1 -i "screenshot.png" -r 30 -i "crash2.avi" -c:v vp9 -b:v 4M -pix_fmt yuv420p -speed 1 -an -filter_complex "[0:v:0][1:v:0][2:v:0]concat=n=3:v=1[outv]" -map "[outv]" -r 30 "merged_3files_30fps.webm"
It seems that RenPy starts skipping a frame at the end at around 30+ fps. It's hard to see with higher framerates. If I press F3 in RenPy to see the the FPS there is always a short dip when the video starts playing and then it's maxed at 60 fps. It's not like the PC isn't powerful enough.
At 30 fps it is still a bit laggy at the start.
This is supposed to be a crash scene so a slow video is not what I prefer. Is it possible to just increase the speed of playing the video, but keep the framrate for the first movie at 20 and the second at 30 fps? Just making the video play fast forward.