Video looping pauses

I’m working on a game where the background is actually a video that needs to be constantly looping. The problem I’m having is the video always pauses for less than 1 second before repeating. I’ve tried different codecs and dimensions for the video but nothing helps. The clips I’ve been testing have been anywhere from 4 seconds to 30 seconds, all have the same issue. Below is the code I’m using to load and display the video.

cm = CardMaker("plane")
cm.setFrame(-1, 1, -1, 1)

plane = render2d.attachNewNode(cm.generate())
movie = loader.loadTexture("Background_loop.avi")

plane.setTexture(movie)
plane.setTexScale(TextureStage.getDefault(), movie.getTexScale())

I’m using Panda3D version 1.7.2 and developing under Windows (Windows 7 64-bit) but the target platform will be Debian.

Does anyone have any suggestions?

Thanks

Do you mean, the video plays its normal full length, and then pauses for a little less than a second, and then repeats, instead of repeating immediately?

I haven’t seen this problem before. Can you post a sample video file that demonstrates the problem?

David

Hi David,
Yes that’s correct, the video plays all the way through and then, before starting over, pauses briefly.

After more experimentation with codecs, I discovered that Xvid MPEG-4 does not have this problem so this is the codec I’ll have to use.

These are the codecs that I first tried which have this problem: H.264/AVC, MPEG-1 and MPEG-2. An FLV file using the H.263 codec actually causes the program to crash if I try to loop it.

Here is the entire code I’m using to test the video looping:

from pandac.PandaModules import loadPrcFileData
loadPrcFileData("", """fullscreen 0
win-size 800 600""")

from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import *
from panda3d.core import *

class Application(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        cm = CardMaker("plane")
        cm.setFrame(-1, 1, -1, 1)

        plane = render2d.attachNewNode(cm.generate())
        movie = loader.loadTexture("loop_xvid.avi")

        plane.setTexture(movie)
        plane.setTexScale(TextureStage.getDefault(), movie.getTexScale())
        
gameApp = Application()
gameApp.run()

And here are links to the test videos I created. This is a stock video as I cannot release the actual game video. This video is 10 seconds and works fairly well as a loop, there is a slight jump from the last frame to the first. But as you’ll see, all the videos pause at the end except the “loop_xvid.avi” file. I’m including the FLV file just to demonstrate the crash.

loop_xvid.avi
loop_h264.avi
loop_mpeg1.mpg
loop_mpeg2.mpg
loop_h263.flv

I don’t see a problem when a play back those alternate textures. Maybe the problem is due to the fairly old version of ffmpeg that we are using in Panda3D 1.7.2 and before (my own Panda is compiled with a more recent version). I believe that rdb has updated the buildbot version to use the most recent version; it might be worth a try to see if it makes a difference.

David

I just downloaded version 1.8.0 and you’re right, the latest version does not have this play back problem.

Thanks for your help!