Playing multiple videos fails

I’m using Panda3D in Python. I have 2 videos, an intro and a “you’ve won”. I use this code to play the intro

        self.introVid = loader.loadTexture ( "intro.mp4" )
        self.introVidSound = loader.loadSfx ( "intro.mp4" )
        self.introVid.synchronizeTo ( self.introVidSound )

        self.screen = OnscreenImage ( image = "colorBars.jpg" , pos = base.camera.getPos() + Vec3 ( .55 , 10 , 2 ) , scale = ( 4.5 , 4.5 , 4.5 ) )
        self.screen.setTexture ( self.introVid )
        self.screen.reparentTo ( self.render )
        self.introVidSound.play()

That works great with both video files. But when I do this again at the end of the game

  • the video doesn’t play at all
  • the audio stutters and only plays for a few seconds
  • then the script hangs completely

There are no error outputs in the terminal otherwise I’d include them here.

What I’ve tried

  • re-rendering the video
  • using a card as a base object instead of an image
  • removing all tasks from the taskmanager
  • unloading the opposite video and all other objects from the scene (either with .destroy() or delete() )
  • Both videos work fine in VLC

Please help and/or let me know what else I can provide!

Scott

  • List item

Do you clean up the OnscreenImage once you’re done with it? I’m wondering whether you’re ending up with two OnscreenImages attempting to play the same video…

Another thought might be to call “unsynchronize” once you’re done with the video.

That said, let me note that the above are somewhat guesses on my part; I don’t know whether one or both of those might do the job.

I do, I just went through and did more robust cleanup to be sure. Also, they are completely separate objects in general. I only combined them to test and troubleshoot. Unfortunately no results / progress. Thanks for the ideas though!

1 Like

Hmm, okay…

Well, a question then: What happens if you run the code for the second video without having run the code for the first video?

And if the problem still occurs, what happens if you isolate the code for the second video into a mini-program of its own and run that?

Question 1: same behavior
Question 1a: I loaded a random MP4 from my Videos folder and saw the same behavior

Question 2: working on that now

1 Like

I moved the code for the 2nd playback into its own mini program like you suggested. Both my original video and a random MP4 I found on my hard drive play fine. I also got a FFMPEG error “bad src frame pointer” or something similar. But again, both files play.

So maybe its being disrupted by other game code but I can’t figure out what. I remove all tasks which doesn’t make a difference and there aren’t any loops or hard waits blocking it

1 Like