Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Streaming video to OpenGl texture

  1. #1
    Junior Member Regular Contributor
    Join Date
    Feb 2007
    Location
    Hungary
    Posts
    168

    Streaming video to OpenGl texture

    Hi,

    I would like to know if there is a better way to stream a video file (e.g. AVI) to an OpenGl texture than what one of the Nehe tutorials suggests (i.e using vfw and AVIStreamGetFrame).

    My problem with this is that a lot of codecs are not compatible with vfw and it is quite slow.

    Of course, I can do this with DirectX and stream the video to a DirectDraw surface then copy every frame from there to an OpenGl texture. But is there a way to make this copy inside GPU memory ('blit') and without involving a much more costly download from GPU than upload it back again?

    Thanks.

  2. #2
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: Streaming video to OpenGl texture

    The ARB_pixel_buffer_object extension seems to suit to your problem. With it, you can benefit from DMA and speed up your texture updates. See the exention spec for more information.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Feb 2007
    Location
    Hungary
    Posts
    168

    Re: Streaming video to OpenGl texture

    I am already using PBOs extensively, the problem is about decompressing a video file frame by frame. The vfw library the nehe tutorial suggests is straightforward, but most of the new codecs are not compatible and it is quite slow.

    DirectX is capable of streaming video to a DirectDraw surface, but if this requires an extra copy to transfer it to opengl, I would like to avoid reading it back from the GPU (DirectDraw surface) to PC memory then transferring it back via PBO to GPU memory. Are you sure this copy would happen inside the GPU?

    Thanks.

  4. #4
    Member Regular Contributor CrazyButcher's Avatar
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    401

    Re: Streaming video to OpenGl texture

    look into the nvidia opengl sdk, they have a sample of using directx decompressing to a PBO

    http://developer.download.nvidia.com...u_videoeffects

  5. #5
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: Streaming video to OpenGl texture

    You may want to read this if it is not already done and then check your pixel size and pixel format.

  6. #6
    Junior Member Regular Contributor
    Join Date
    Feb 2007
    Location
    Hungary
    Posts
    168

    Re: Streaming video to OpenGl texture

    Although I could not yet compile the nvidia sample, at first glance the contents of a frame of video is being passed to a directx surface (afaik the equivalent of an opengl texture) which is a - hopefully - asynchronous upload to the GPU, then being read back to PC RAM. Then, using PBOs it is uploaded again asynchronously to the GPU, this time to an opengl texture.

    This looks like two extra steps compared to if I used directx and not opengl. Even if all this is asynchronous on the CPU side it still requires an extra effort from the GPU and is an extra load on the bus.

    Am I mistaken in my assumptions? If not, is this still the best way to stream video to an opengl texture?

    Thanks,

  7. #7
    Member Regular Contributor CrazyButcher's Avatar
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    401

    Re: Streaming video to OpenGl texture

    the nvidia sample doesnt read back to RAM but to PBO directly, then to texture. Yes there is one more "action" then using directx directly, but there is no readback to regular RAM.

    OpenGL:
    dsurface -> PBO (two alternating PBOs used) -> texture

    DirectX:
    dsurface -> dtexture

    nvidia also has sample for the latter method in their SDK. Be aware to read the notes about compiling those demos, you will need some content of older directx sdks to get the dx9/dxshow renderer.

  8. #8
    Junior Member Regular Contributor
    Join Date
    Feb 2007
    Location
    Hungary
    Posts
    168

    Re: Streaming video to OpenGl texture

    Thanks guys. I will investigate this. If only I didn't hate directshow...

  9. #9
    Advanced Member Frequent Contributor yooyo's Avatar
    Join Date
    Apr 2003
    Location
    Belgrade, Serbia
    Posts
    872

    Re: Streaming video to OpenGl texture

    Check examples Texture3D and Texture3D9 in DirectShow SDK (part of older DXSDK). Remove DX stuff, add PBO stuff and thats it.
    If you still have problem, send PM and I'll give you my classes for video to texture.

  10. #10
    Junior Member Regular Contributor
    Join Date
    Feb 2007
    Location
    Hungary
    Posts
    168

    Re: Streaming video to OpenGl texture

    Thanks, luckily I had Directshow already installed on my PC. After having suffered for half an hour because of unicode, ATL and VS2005 problems I successfully recompiled my Dshow base classes and the Texture3D9 sample now works.

    Now I can play with it a little.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •