Video Texture player

Taken from The Blender Game Reference, Section 25.3.4 “Available File Formats”

The height and width of textures should be to the power of 64 pixels (e.g. 64x64, 64x128, 128x64 etc.) or Blender has to scale them (in memory not on disk!) to provide OpenGL compatibility

Since 128 x 64 is not a power of 64, I assumed the words “to the power of” were a typo, and the words “a multiple of” were intended. It seems “64 pixels” was the real typo, and “2 pixels” was intended…

This is confirmed in the newer BGE 2.41 Material Docs in “Image Types” were it does say “power of 2” like you said, and that code you posted seems about as clear as can be. I had a texture in my Marble Labyrinth game at 1024 x 768, and it was kinda blurry at some angles. I set it to 512 x 512, and it’s 100% clearer and runs about 33% faster. Thanks for clarifying that for me. (accidental pun)

New update in Video Texture plugin allows to generate textures with transparency from “blue screen”. Demo contains example of this effect.
I have also done complex refactoring of internal classes to make futher development easier.

:confused: I pressed enter and space. No matter what I do all I can see is the x’s on the different planes.:confused:

I’m running with an intel pentium D CPU 3.00GHz, 1 GB of RAM
and I have a ATI Radeon X1300 as my graphics card

tml4ever14,

check if your codec supports output in RGB24. If not, texture renderer refuses to render video and video is rendered in separate window.

Just want to say thanks a million for this Ashsid. It is going to be very useful for my research (I study child psychology and I need to show children videos inside of a simple computer game).

I am a little confused about how the plugin works with materials and textures. The demo works very well for me. But my problem is that when I try and create my own .blend using the plugin, it never works and I also get an error log created with

.\TexPlayer.cpp:152:0       : Texture material is not available

.

I did as follows: started a new .blend, created a plane, created a material for it, UV mapped the same .png on to it as you use in the demo, and then duplicated all the python game logic from the demo.

I know that the materials/textures is my only problem, because if I disable their use with

blendVideoTex.setBlendMat(0)

, the video displays fine (actually that surprised me, the documentation lead me to believe that it would crash if I said there were no materials when there are).

I have tried a variety of value for the last two parameters in this command (without success):

 
GameLogic.player = blendVideoTex.TexPlayer(obj,'scanner_darkly01.avi', 0, 0)

I must admit, I don’t really feel like I completely understand how UV and image textures work in blender anyway. I notice that in the demo you have, as well as a UV map, a non-UV image texture under the F6 tab. I don’t really understand the point of that (I have never been able to get those kinds of image textures to do anything useful). I don’t understand the relationship between the UV map and the non-UV image texture on the F6 tab. Anyway, creating that non-UV texture in my test .blend does not solve my problem.

Cheers,

Ben

amorphia,

if you use Blender materials options, game engine doesn’t use UV mapped texture, but texture defined in material.

If you don’t add texture image to material, plugin won’t find it and issue error - like you have already discovered.

In demo there are both kinds of texture used to be able to run with and also without Blender materials enabled.

Maybe you could upload your file so I would be able to check what’s wrong with it.

Oh, I see, thanks for the explanation.

My file has both a UV map and a non-UV image texture also. But only the non-materials method works. I would very much appreciate it if you would take a look at it and tell me what I did wrong.

Cheers,

Ben

I have tried it and it works for me in both modes with or without Blender Materials.
Which version of Blender do you use? Plugin is compiled for 2.41 and I didn’t tested it on release candidates for 2.42.

Thanks a lot for testing that for me, Ashsid. I am using the standard 2.41 version so this is rather odd. However, I was already begining to have my suspicions that something is not quite right on my system, with regard to image textures. They don’t seem to work for me quite as I think they should. As a relative newbie it seems more likely that there is something I have misunderstood, than that there is a bug, but this test really seems to suggest there is a problem with my system.

For example, in the file I sent, if I press TexFace Delete on the Editing Panel, to delete the UV data, then the plane become totally black. But, I think an image texture should still be displayed, right?, because I have only deleted the UV map, and there is still a non-UV image texture.

Would you possibly mind confirming that for me? That way you can be certain that there is something wrong with my system, and you don’t need to be concerned about your plug-in. I can then get help elsewhere. I suppose it could be my video card?

Thanks for the help,

Ben

I am trying to delete this accidental post but can’t work out how! Please ignore it!

Hi there,

I hope you don’t mind, Ashsid, I just have one more question, about how you are supposed to restart the video once it has stopped. I find that the only way to replay the movie is to recreate the object by calling the constructor again (in the same way), followed by play() again. Is that the way it should be? I thought it was more appropriate to do it like this:

playstart.py:

import blendVideoTex
if hasattr(GameLogic, 'player') == 0:
  contr = GameLogic.getCurrentController()
  obj = contr.getOwner()
  GameLogic.player = blendVideoTex.TexPlayer(obj,'Video/scanner_darkly01.avi', 0, 0)
  GameLogic.player.repeat(1)
  GameLogic.player.play()
else:
  print "Trying to play again
"
  GameLogic.player.play()

playing.py:

import blendVideoTex
if hasattr(GameLogic, 'player') != 0:
 state = GameLogic.player.getState()
 if state == 3:
  GameLogic.player.close()

But I find that even after I call close, state still stays at 3. I thought it would go to 1. Perhaps what is missing is some kind of rewind() function? Or is it really OK to keep constructing the object every time I want to play the video?

By the way thanks again for a really cool addition to blender, even with these things which I don’t quite understand, I am confident it is going to be really useful for me!

Cheers,

Ben

Hi,

it seem to be a bug - video should be able to replay by calling play() again. I will look at it and post corrected version ASAP.

Ash

Yes, it was bug. Methon play() is supposed to do 2 different things:

  1. if video replay was stopped in the middle, play() will continue from place, where it was stopped.
  2. if video was stopped because it has finished replay, play() will restart replay from starting position.

The second option was broken and is now fixed.

Hi I am really keen on getting this video plugin to work … but it doesn’t.

I downloaded the demo zip file today, and have coppied all the blender main directory.

I tried it with 2 versions of blender:
this is what happens when I press p (for play), and then <Enter> or <Space> to start the videos.

2.41:
in the left of the 2 sided tv box I get the black cross/circle on white background, and to the right I get the black cross/circle with no background… the enter/space keys don’t do anything, and no change in blender’s output window

2.42 RC3:

similar to 2.41, but cross/circles are distorted (look more like lines). when I press <enter>, blender crashes, (displays windows error message)

[SIZE=1]AppName: blender.exe AppVer: 0.0.0.0 ModName: blendvideotex.dll
ModVer: 0.0.0.0 Offset: 000011c6

This is what I am running:
windows XP
Compaq presario with AMD 2500+
NVIDIA GeForce FX5100 (64MB)
directX 9.0c
Just installed XVID codec XviD-1.1.0-30122005 Final Release
Python 2.3 and 2.4 installed

the videos in the demo zip run in media player 5.1 and 9 on my machine

Is there any way to debug what is going on in the plugin? Blender’s text output window displays nothing.

any help is appreciated.

[/SIZE]

dazzler,

for 2.41 blender, have you looked at content of file exptLog.txt? Are there any errors written?

Many thanks for the bug fix Ashsid! Works great for me now.

Ben

Ashid,

thanks so much for your reply.

I found exptLog.txt in my documents directory. here is what it outputs when I try to run the blend file:

.\RenderDShow.cpp:67:80040216: Source file failed to open

dazzler,

that means game hasn’t access to video files (they are in a different folder than working folder). Try to add full path to video files in scripts or move video files to “My Documents” folder - it seems that it is working folder.

thanks ashsid - it works! that’s awesome !!! :slight_smile: you rock
…well it only partly works, but it’s a start.
I coppied the video files to my documents directory like you said. That got it to work in the blender 2.41 program :slight_smile: It’s strange that it looks for these files in that directory.???:confused:

It still doesn’t work in blenderplayer for 2.41 - the videos just don’t start when you press enter or space, and the following message is written to exptlog.txt:

.\TexPlayer.cpp:152:0 : Texture material is not available

maybe there’s an option I have to enable for textures in gameblender … I’ll keep looking.

btw it still crashes blender 2.42 RC3, with this error message:

AppName: blender.exe AppVer: 0.0.0.0 ModName: blendvideotex.dll
ModVer: 0.0.0.0 Offset: 000011c6

…and no message is written to exptlog.txt

I just got it to work in gameblender 2.41. I had to run it on a commandline with these options:

blenderplayer -g blender_material = 1 scanner_darkly.blend

also, whenever I exit blender or gameblender after running the demo file I get this message on exit (exaple message is from blenderplayer)

SDL_app: blenderplayer.exe - Application error
The instruction at “0x03979790” referenced memory at “0x039a41a8”. The memory could not be “read”.
Click OK to terminate the program.

dazzer.