Reputation:
I have a video file, called intro.mpg that plays a 2 minute intro. It's properties are as follows:
Length: 02:23
Frame Width: 800
Frame Height: 600
Data Rate: 18500 kbps
Total Bitrate: 18884 kbps
Frame Rate: 50 fps
Bit Rate: 384 kbps
Channels 2 (stereo)
Audio Sample Rate: 44 kHz
Does pygame require a certain type of video file with certain properties, or is it my code:
import sys
import pygame
pygame.init()
pygame.mixer.init()
mov_name = "resources\\video\\intro.mpg"
screen = pygame.display.set_mode((800, 600))
video = pygame.movie.Movie(mov_name)
screen = pygame.display.set_mode(video.get_size())
video.play()
while video.get_busy():
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
'Cause this is all I get:
Upvotes: 4
Views: 1114
Reputation: 100
You event loop is not sleeping for some time. So computer is running as fast as it can.Your code is using too much cpu. And there is not enough cpu time to play the movie.
Solution: Try this code:
import sys
import pygame
pygame.init()
pygame.mixer.init()
mov_name = "path_to_file"
clock=pygame.time.Clock()
####screen = pygame.display.set_mode((800, 600))
video = pygame.movie.Movie(mov_name)
w,h=video.get_size()
screen = pygame.display.set_mode((w,h))
video.set_display(screen,(0,0,w,h))
video.play()
while True:
event=pygame.event.wait()
if event.type==pygame.QUIT:
pygame.quit()
sys.exit()
Upvotes: 1