justinstenning / Direct3DHook

DirectX Capture and Overlays by using Direct3D API hooks
http://spazzarama.com/2011/03/14/c-screen-capture-and-overlays-for-direct3d-9-10-and-11-using-api-hooks
MIT License
580 stars 178 forks source link

Use Direct3DHook with FFmpeg #64

Closed grill2010 closed 6 years ago

grill2010 commented 6 years ago

Hi,

as you may remember I'm building a PS4 Remote Play interceptor program which lets the user control a PS4 remotely and stream the captured content via UDP to a Smartphone. We had a discussion about speeding up the capture process and for that I used your SharedMemory project which worked great. In addition to that I used a library called FFmpeg autogen to generate a video stream. The results are great and it worked very good. However I'm constantly trying to improve the performance so I thought instead of sending the captured image data from the PS4 Remote Play process to my own program and perform all the UDP sending logic and the FFmpeg video compressing stuff there I would rather like to video compress the captured image data in the captured process and send it via UDP directly to the target (Smartphone).

The FFmpeg autogen library links to these native dlls via a dynamic loading mechanism which can be found here. As this mechanism works in my own target process I could not manage to make it work in the captured target process. The result of the "SetDllDirectory" method returned true but as soon as I want to use one the FFmpeg autogen methods I get an error that some of the native dlls could not be found. The FFmpeg autogen is basically a wrapper around this native FFmpeg functions but it seems that this libraries are not loaded correctly in the captured target process. Maybe something with the AppDomain? Please let me know if you have any ideas and many thanks for your help.


Edit: The native libraries in FFmpeg get loaded via

DllImport("kernel32", SetLastError = true)]
public static extern IntPtr LoadLibrary(string dllToLoad);

I tried to call this function manually but it doesn't work.

grill2010 commented 6 years ago

I closed the issue, it was my fault. I used the dependency walker to check the FFmpeg libraries. As I compiled FFmpeg with libopenh264 I needed to load that library before all FFmpeg libraries. After that it worked.