I developed a game that uses 4 second video clips that are played in random order as the background animation but while testing discovered the game crashes when running it for several days. A requirement of the game is that it runs 24 hours a day in an arcade.
I’m running it under Ubuntu 10.10 32-bit with Panda3D 1.7.2. The problem has been reproduced on three machines all with the same hardware specs: Celeron 430 (1.80GHz), 4GB DDR3, NVIDIA GeForce 8400 GS (512MB)
I have tried encoding the videos using H.264 and MPEG4 Xvid. I noticed when using the videos encoded with MPEG4 Xvid, the memory leak is actually slower than when using H.264.
For example when using MPEG4 Xvid, it took almost 3 hours to increase memory usage by 0.6%. But using H.264, the memory usage increased by 2.4% in only 45 minutes. I’m using the System Monitor in Ubuntu for monitoring the memory usage.
The small program below demonstrates this problem. I can’t provide the videos for the example code since the game has not been released yet. If it would help I could find some free stock videos and provide those.
from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
from pandac.PandaModules import *
# Video dimensions
VIDEO_WIDTH = 1360
VIDEO_HEIGHT = 768
class Application(ShowBase):
def __init__(self):
ShowBase.__init__(self)
props = WindowProperties()
props.setOrigin(0, 0)
props.setSize(VIDEO_WIDTH, VIDEO_HEIGHT)
props.setFullscreen(0)
base.win.requestProperties(props)
cm = CardMaker("backgroundPlane")
cm.setFrame(-1, 1, -1, 1)
self.backgroundPlane = render2d.attachNewNode(cm.generate())
self.movies = [BackgroundAnimation("Background01.avi", "videoEnded"),
BackgroundAnimation("Background02.avi", "videoEnded"),
BackgroundAnimation("Background03a.avi", "videoEnded"),
BackgroundAnimation("Background03b.avi", "videoEnded"),
BackgroundAnimation("Background04.avi", "videoEnded"),
BackgroundAnimation("Background05.avi", "videoEnded"),
BackgroundAnimation("Background06.avi", "videoEnded"),
BackgroundAnimation("Background07.avi", "videoEnded"),
BackgroundAnimation("Background08.avi", "videoEnded"),
BackgroundAnimation("Background09.avi", "videoEnded")]
self.accept("videoEnded", self.videoEnded)
self.currentMovie = 0
self.movies[self.currentMovie].play()
def videoEnded(self):
self.movies[self.currentMovie].stop()
self.currentMovie += 1
if (self.currentMovie >= len(self.movies)):
self.currentMovie = 0
self.backgroundPlane.setTexture(self.movies[self.currentMovie].getVideo())
self.backgroundPlane.setTexScale(TextureStage.getDefault(), self.movies[self.currentMovie].getVideo().getTexScale())
self.movies[self.currentMovie].play()
return
class BackgroundAnimation:
# videoFile - video file
# finishEventName - event that is fired when the video finishes playing
def __init__(self, videoFile, finishEventName):
self.video = loader.loadTexture(videoFile)
self.sound = loader.loadSfx(videoFile)
self.video.synchronizeTo(self.sound)
self.sound.setFinishedEvent(finishEventName)
return
# Start playing the video
def play(self):
self.sound.play()
return
# Stop playing the video
def stop(self):
self.sound.stop()
return
# Return the video object
def getVideo(self):
return self.video
Thanks