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
582 stars 176 forks source link

How can i save screenshots to the hard disk according to the fps the program get from a game ? #14

Closed Csharper1972 closed 9 years ago

Csharper1972 commented 10 years ago

For example i'm running a game inject and hook the game and i see on the game window the frames per second running in this case for example average of 60-61fps. Now i want that the program will automatic save to the hard disk screenshots captured every second 60-61 images. Just like the program get from the game if it's 60fps then save 60 images on hard disk in a second if it change to 43fps then now save 43 images to the hard disk.

I did changes and added my code to the file DXHookD3D9.cs

This is the changes i did: http://pastebin.com/wc7vxQvD

First at the top i added: long counter = 0; Then under: #region Screenshot Request i added my own IF with a request inside. Then more in the bottom inside the ProcessRequest method i added my oqn thread called it t_1 and after this method added my oqn code with my oqn method called: SaveToDiskImageData

The problem is that it's too slow it's not saving to the hard disk 60-61 frames(screenshots/images) per second and another problem is after some time it's wroking when it's saving like 1000 images to the hard disk it's throwing an exception.

What i want to do in general is first to capture and save to the hard disk the images in real time according to the current fps and then later if it will work to create in real time an avi file.

But first how do i make this part to work good ?

This is the link again to the changes i did in DXHookD3D9.cs: http://pastebin.com/wc7vxQvD

remcoros commented 10 years ago

You don't want to be writing so much files per second. Writing 60 files per second (18.000 for 5 minutes) is never going to work, considering that the screenshots are not compressed in any way (raw pixel data). If you compress them, it would still be to slow for any decent hardware.

If your final output should be a video / stream, you should buffer the input and live encode to a video stream/file.

Basically, what the guys over here have done: https://github.com/jp9000/OBS

Not an easy task though.

Csharper1972 commented 10 years ago

remcoros thanks i will try to look into it sometime, looks very hard.

justinstenning commented 9 years ago

Split into two new tasks #33 and #34