I want to play an avi file. I created an egg file and tried setting its texture as the avi file. It just doesnt work. Can you please help me? The code is as follows:
I played around with this 2 days ago. This is the code that I came up with:
#create object
cm = CardMaker('Movie')
movieCard = render2d.attachNewNode(cm.generate())
movieCard.setPos(-1,0,-1)
movieCard.setScale(2,1,2)
#set movie texture
myMovieTexture=loader.loadTexture("test128.mpg")
movieCard.setTexture(myMovieTexture)
myMovieTexture.play()
Using the CardMaker I create a square that fills the screen. Otherwise your code looks a lot like mine. Do you get an error on the commandline? Perhaps the correct codec for the video was not found?
Thank You:) I tried that too. It doesnt work though.
I get this error:
TypeError: NodePath::set_texture() argument must be Texture, not None Type.
Do you have any idea how to get around this problem? I guess its a problem with the codec. I created a wmv file using Movie maker and converted this to an avi file using BlazePro. Do you have any suggestions?
well ,avi files can use different codecs. (i dont know blazepro…but )perhaps blazepro allows you to choose the codec you want to use, perhaps changeing it will help.
try to figure out which codec blazepro uses.
perhaps using virtualdub or mencoder can create a file with supported codec if you cant get it to work with blazepro.
have you already checked if your code works with a “proven-to-work-texture”?
I have been experimenting a bit using the above code. After trying 5 different .avi files, I keep getting the following trace (with ‘info’ level messages):
:grutil(error): OpenCV couldn't read /c/dev/Djerlani/textures/test2.avi as video.
:gobj(error): Texture "/c/dev/Djerlani/textures/test2.avi" exists but cannot be read.
Traceback (most recent call last):
File "C:\dev\Djerlani\main.py", line 4, in ?
import Myw
File "C:\dev\Djerlani\Myw.py", line 35, in ?
myObject.setTexture(myMovieTexture)
TypeError: NodePath::set_texture() argument 1 must be Texture, not NoneType
:display: Closing wglGraphicsWindow
Well, the point is not so much that the setTexture method does not work, (setting a priority is optional), but that the loadTexture comes back with a NoneType.
The error ‘:gobj(error): Texture “/c/dev/Djerlani/textures/test2.avi” exists but cannot be read.’ implies that there is something wrong with the file or the codec.
The problem at this point is to find out what exactly and fix it
It was just the first square movie file google pointed me too . This one works for me, although it seems the “quality of the decoding” is not very good, e.g. a lot of blocks from a previous mpeg frame remaining visible in the next. If anyone has good experiences with a certain codec, I’d love to learn which one!
You appear to be using an older version of Panda, which used OpenCV for video texture support. The most recent version of Panda uses the ffmpeg library for video texture instead, and this library is much better able to load a variety of different video formats.