Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-02

How to capture DirectShow Overlays from Players/Games

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Razvan Adrian Bogdan

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 :)

Razvan

Reply by email

Christian Iversen
to Razvan Adrian Bogdan
Razvan Adrian Bogdan wrote 10 lines
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

Reply by email

Razvan Adrian Bogdan
to Christian Iversen
Christian Iversen wrote
The question you pose is interesting, but not really related to lazarus at all.

It is not related to Lazarus itself but how to achieve something in Lazarus (and possibly Delphi) apps.

In a side note, not that many games use overlays. Can you tell me what you are trying to achieve?

It is not intended specifically for games, i am trying to create a screenshot (possibly record) of everything on screen or a specific window over which i have some control. Let's say make a screenshot of the desktop with a running media player or just the media player then process that image. Because DirectShow codecs use overlays this is not possible with traditional GDI methods.

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

Hacky is no problem, it just has to work, many things are hacky on Windows.

Show quoted text 6 lines
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

Where do i obtain this pointer from, any links, docs ?

Show quoted text 7 lines
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)

How is this done ? It is not an option for me to install anything on the system that might interfere with other activities, installing a driver or codec is not a posibillity.

Show quoted text 11 lines
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.

This would be good but it is out of my control to disable overlays, i'm at the mercy of preinstaled codecs and the people using them.

Thank you for the suggestions, i am trying out OpenSource apps that claim to do capturing from DirectX or Windows Media but none seems to work, all return the classic black rectangle in place of the clip.

Razvan

Reply by email

Felipe Monteiro de Carvalho
to Razvan Adrian Bogdan
Razvan Adrian Bogdan wrote 8 lines
> 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 Where do i obtain this pointer from, any links, docs ?

Here is an example project that uses overlays so you can see what kind of code you need to write:

http://magnifier.svn.sourceforge.net/viewvc/magnifier/trunk/libraries/pas_overlays/pas_overlays.dpr?revision=86&view=markup

It doesn't read anything from the overlays, but rather writes a magnifyed image of the screen to it.

Having said that, I have o idea how to read the overlays. Ask on Microsoft directx newsgroups or google.

Felipe Monteiro de Carvalho

Reply by email

Marc Weustink
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 19 lines
On Feb 19, 2008 6:02 PM, Razvan Adrian Bogdan wrote: >> 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 > Where do i obtain this pointer from, any links, docs ? Here is an example project that uses overlays so you can see what kind of code you need to write: http://magnifier.svn.sourceforge.net/viewvc/magnifier/trunk/libraries/pas_overlays/pas_overlays.dpr?revision=86&view=markup It doesn't read anything from the overlays, but rather writes a magnifyed image of the screen to it. Having said that, I have o idea how to read the overlays. Ask on Microsoft directx newsgroups or google.

I fear that it is not possible. Overlays are drawn in a separate buffer and then rendered on screen by the videocard itself (based on some color replacement)

Marc

Reply by email