[Lazarus] How to capture DirectShow Overlays from Players/Games

Christian Iversen chrivers at iversen-net.dk
Tue Feb 19 13:33:23 CET 2008


Razvan Adrian Bogdan wrote:
> Did anyone try to capture DirectShow Overlays from movie players or
> games using DirectX ?
>>From what i've read this is quite tricky even for a simple screenshot.
> 
> The problem is that overlays are mapped to the video memory and shown
> on the screen using a custom background color that gets replaced with
> data from the video memory and when doing the screenshot only the
> background color is captured.
> 
> Any ideas are highly appreciated :)

The question you pose is interesting, but not really related to lazarus 
at all. In a side note, not that many games use overlays. Can you tell 
me what you are trying to achieve?

However, there are several ways one might go about doing something like 
this. They are all hacky, but varying degree.

A) Assume the overlay stays in place in memory (ugly)
   1) Create an overlay of (approximately) the same size as the target
   2) Keep the pointer to the memory location
   3) Destory the overlay
   4) Start the application
   5) Read the stored memory position

   If you are lucky, then:
     1) This position is indeed still valid
     2) This position is mapped to VRAM on the graphics card
     3) You will be able to read the data from there (but you
        will not know when new frames arrive)

B) Create a DLL proxy (bad)
   1) Create a new DLL file dshow.dll (dshow9.dll?). This will
      be your proxy
   2) For all the functions in the real dshow.dll, use GetProcAddress()
      to find the corresponding function in dshow.dll. For the overlay
      functions, implement them yourself. This allows complete control
      over the process. You can then do anything you want with the
      overlay data.

C) Work around the need to capture the overlay (good)
   1) If what you need to do is perform some action,
      it might be easier to re-implement the functionality.

-- 
Med venlig hilsen
Christian Iversen



More information about the Lazarus mailing list