Login
 
Archive
Links
Search
Blog List
There are no categories in this blog.
 
Nov 7

Written by: Jeremiah Morrill
11/7/2008 5:15 AM 

I don't have a whole lot of time, even for this post.  Been bombarded with work.  I still wanted to share my latest concoction.

Simply put, I am able to grab the Direct3D shared Surface the Vista DWM uses (undocumented API) to paint all Direct3D based windows.  Once I have that, I am able to use it as a "VisualBrush" in WPF or I can copy the Direct3D Surface to system memory for very high frame rate captures.and you can stream it out too.to Silverlight even!  This idea is similar in concept to Fraps, but Fraps uses DLL injection and method hooking (I suspect).

Here is a video showing a Direct3D sample application (lower left), also rendering to a WPF application (upper left, notice the cliché reflection), then you have it being streamed to a Silverlight MediaElement (wmv format), in real-time. (On a side note, SL streaming service is great compared to the quality of YouTube.  Check it out in fullscreen!)

 

Here is a WPF application being streamed to Silverlight. 

 

Here is the source for the application.  It's very ugly code, but it's only a quick prototype I threw together.  I use SlimDX, so if you have any issues using it, make sure to install the latest DX runtimes here.

http://jmorrill.hjtcentral.com/Portals/21/blog/DxCapture.zip

Note, if you wish to just render the DWM surface to the application, leave the output filename blank and do not select "network stream".  If you wish to stream the application video, just check the network stream checkbox and you can open the video in Windows Media Player by opening the url:  http://localhost:selectedport/

-Jer

 

Tags:

10 comment(s) so far...

Re: Vista DWM Hacking – Capture and Stream D3D/WPF Windows Real-Time

Jer, that is so cool!

Just gave the example a quick test and it works realy good, even with a video window as "source".

Is it possible to have a WPF sufface (canvas) as "source"? Then I could make my own "TV station" mixing video with fx add text in WPF and stream it to a media player.

/Ken

By Ken on   11/10/2008 4:05 AM

Re: Vista DWM Hacking – Capture and Stream D3D/WPF Windows Real-Time

Thanks Ken!

You can not use a specific WPF visual as the "source", only the entire top level window of a DX/WPF application. You could create a WPF application that used one window to display all your "TV Station" visuals and another window for controlling your "TV Station" and only use your one window as the "Source"


-Jer

By Jeremiah Morrill on   11/10/2008 4:38 AM

Re: Vista DWM Hacking – Capture and Stream D3D/WPF Windows Real-Time

If you like it, BTW, please give me a "Kick" on dotnetkicks!

http://www.dotnetkicks.com/wpf/Vista_DWM_Hacking_Capture_and_Stream_D3D_WPF_Windows_Real_Time

By Jeremiah Morrill on   11/10/2008 5:20 AM

Re: Vista DWM Hacking – Capture and Stream D3D/WPF Windows Real-Time

Yes that works fine (even with WindowStyle = WindowStyle.None)

however, I also need sound... I asume that I can add line in or "what U haer" from the windowmixer, to the "CwmvFile", have you tested?

And, do you think it's possible to start/stop rendering to file (so I can create new files) without stoping the streaming. Or maybe I can just have several "CwmvFile" classes on the "DwmCapture" class.

/Ken

By Ken! on   11/10/2008 6:47 AM

Re: Vista DWM Hacking – Capture and Stream D3D/WPF Windows Real-Time

Hi all, I get blank black backgound in the WPF app and also black video stream :( Anyone can help?

By DragoraN on   11/17/2008 3:58 PM

Re: Vista DWM Hacking – Capture and Stream D3D/WPF Windows Real-Time

DragoraN,

You must specificy a window that is Direct3D based, ie video game or WPF application.

By Jeremiah Morrill on   11/17/2008 4:35 PM

Re: Vista DWM Hacking – Capture and Stream D3D/WPF Windows Real-Time

Thank you Jeremiah, it was not clear for me from the post.
One other question. I am experiencing major delay in network stream. It is delayed about 5 seconds after i make change to source. In the post I can see that it is matter of miliseconds, how it is possible? Can you advice please?

By DragoraN on   11/17/2008 5:29 PM

Re: Vista DWM Hacking – Capture and Stream D3D/WPF Windows Real-Time

If you watch closely, the video's on this page are also delayed about 5 seconds. This is a side effect of the Windows Media Format SDK and how it automatically buffers video server and client side. The only way to get real time, is to use another streaming method/library. You have access to the uncompressed bitmap in the code, so the video source should not be an issue.

-Jer

By Jeremiah Morrill on   11/17/2008 5:52 PM

Re: Vista DWM Hacking – Capture and Stream D3D/WPF Windows Real-Time

Hi!
I have some question about DWM and related feature.
My project wanna a feature that all output of screen be stored in a offscreen buffer, a program do some modify of the buffer, for example twist the screen image or make output brighter or darker, then the modified result be sent to the real screen.

It is just something like flip3d in vista.
Do you think it is possible to achieve?
Please give me some suggestion :)

By Fu Chen on   11/19/2008 12:00 AM

Re: Vista DWM Hacking – Capture and Stream D3D/WPF Windows Real-Time

Hi!
I have some question about DWM and related feature.
My project wanna a feature that all output of screen be stored in a offscreen buffer, a program do some modify of the buffer, for example twist the screen image or make output brighter or darker, then the modified result be sent to the real screen.

It is just something like flip3d in vista.
Do you think it is possible to achieve?
Please give me some suggestion :)

By Fu Chen on   11/19/2008 12:05 AM

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 
  Minimize
Text/HTML Minimize
Copyright 2007
Downloaded from DNNSkins.com