I've been looking around for a while trying to find a way to display videos in Pygame because of a new story video-game project. I finally stumbled across Moviepy which works alright...except that the video displays showing only one of the 24 frames each second and the window it displays in is bigger than by screen. (on a Windows 10 laptop with an 11inch(I think) screen)
The sound is alright but the video also goes too fast so is out of sync.
I've tried the resize function as said on the docs but it gives no effect.
And I can't find anything to do with the framerate.
So I need a way to make the window smaller and correct the framerate.
This is the code I used:
from moviepy.editor import VideoFileClip
from moviepy.video.fx.resize import resize
import pygame
pygame.display.set_caption('My video!')
clip = VideoFileClip('Eleeza Crafter And The Cloud Colours Trailer.mp4')
clip.fx(resize, width=240)
clip.preview(fps=24)
pygame.quit()
Any help would be appreciated. Thanks :)
EDIT: I tested a different video at the same framerate and it works perfectly? Then again it was just a simple line flying around the screen.
A 2 seconds google gave me this link.
It states :
A clip can be previewed as follows
my_clip.preview() # preview with default fps=15
my_clip.preview(fps=25)
my_clip.preview(fps=15, audio=False) # don't generate/play the audio.
my_audio_clip.preview(fps=22000)
Also (depending of your import method:
This way you can use
clip.resize(width=240)
instead of the longerclip.fx( resize, width=240)
.
Still from the documentation:
For advanced image processing you will need one or several of these packages. For instance using the method clip.resize requires that at least one of Scipy, PIL, Pillow or OpenCV are installed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With