Horde3D http://horde3d.org/forums/ |
|
Playing videos in horde http://horde3d.org/forums/viewtopic.php?f=2&t=1189 |
Page 1 of 1 |
Author: | Irdis [ 28.06.2010, 11:00 ] |
Post subject: | Playing videos in horde |
I'm trying to play videos on some textures of my 3d scene. For decoding I use FFmpeg. Everything is fine until I try to change textures in horde (so, everything is decoded correctly, h3dutCreateTGAImage works successfully). If I use only LoadResource then horde loads only the first frame of the video. If I use UnloadResource before it everything works, but I get 10 fps (normally the speed of the scene is more than 70 fps with 8xAA). Even with writing every frame to disk I got 23-25 fps with antialiasing. And with unloading texture resource and no AA I get 11 fps I tried creating texture resource with different flags, like no compression, dynamic textures and other, but situation is the same. I tried to use h3dMapResStream to directly modify the texture, but for some reason I get a null pointer and an "Invalid operation in h3dMapResStream" (even for reading. Maybe because I tried it after AddResource operation and texture data was not yet uploaded). Any ideas? |
Author: | MistaED [ 28.06.2010, 13:10 ] |
Post subject: | Re: Playing videos in horde |
Hi Irdis, What are the specs for this video, like what resolution is it and what codec/bit-rate? If it is an non power of two try making it one and see what the performance is like. I'm not too sure how to use mapstream so I can't really help there. Using blender's video2texture approach with a 1080p video it wasn't very good performance-wise either. http://www.opengl.org/registry/specs/AR ... object.txt http://developer.nvidia.com/object/fast ... sfers.html You might need to extend horde to support PBOs or something to get better performance, I'm not sure. |
Author: | AlexL [ 28.06.2010, 14:39 ] |
Post subject: | Re: Playing videos in horde |
You definitely have to use the mapStream functionality in Horde, which dynamically uploads the new texture data. Internally it does use glTexImage2D (replacing the old texture, which seems a bit faster than using glTexSubImage2D). We use this approach to dynamically upload new textures, and even a decent graphics card will allow an upload of 500MB/sec (e.g. NVIDIA 8600M GT, running Linux in Parallels, so virtualized). The basic outline is: Code: - Use dynTex = ::h3dCreateTexture("$DYN_TEXTURE", videoWidth, videoHeight, TEX_BGRA8, H3DResFlags::NoTexMipmaps); to create a new texture - be careful to chose a name which is not yet occupied! Use TEX_BGRA8 as format - your video needs to be converted in this format or you have to patch the renderer to support BGR only - Find the material resource you want to apply the video texture to matRes = ::h3dFindResource(H3DResTypes::Material, matName); - Find the sampler index within the material int samplerIndex = h3dFindResElem(matRes, H3DMatRes::SamplerElem, H3DMatRes::SampNameStr, samplerName); // samplerName sth like "albedoMap" - Apply the dynTex to the material h3dSetResParamI(matRes, H3DMatRes::SamplerElem, samplerIndex, H3DMatRes::SampTexResI, dynTex); - You do this only once. Then after getting a video frame from ffmpeg, upload it to horde (which will upload it to GL) void *mappedData = h3dMapResStream(dynTex, H3DTexRes::ImageElem, i*countsPerSlice+mip, H3DTexRes::ImgPixelStream, false, true ); // (i, countsPerSlice and mip are only relevant if you have a mipmapped and/or cube texture, otherwise just set it to 0) // copy image data over to horde's internal buffer memcpy(mappedData, ffmpegVideoFrame, textureSize); // with texture size being videoWidth*videoHeight*4 in case of BGRA8 // tell horde to upload data to GL h3dUnmapResStream(dynTex); Hope this gets you going. In our case a PBO approach wasn't really worth it. One could also avoid the memcpy, if horde accepts a raw memory pointer, but this might only work for OpenGL. Alex |
Author: | Irdis [ 28.06.2010, 16:49 ] |
Post subject: | Re: Playing videos in horde |
MistaEd, video file is xvid encoded, 720*480, bitrate about 1800. It takes little time to decode (if I don't update the texture in horde decoding is not even noticable). Thanks for links. Great work on the ES port, by the way)) AlexL, thanks alot, everything worked! |
Author: | zester [ 28.12.2010, 22:29 ] |
Post subject: | Re: Playing videos in horde |
Could you post a working example on how you got ffmpeg working? |
Author: | korty [ 05.01.2011, 10:42 ] |
Post subject: | Re: Playing videos in horde |
Hi zester, you could look at http://hcm-lab.de/public/Horde3D/trunk/ ... Component/ (Further details can be found here: http://hcm-lab.de/projects/GameEngine/d ... ials:vidoe) Maybe you find some piece of code that is useful. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |