-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert frame with FFMPEG #25
Comments
The swap chain is only to display the contents of the frame, it's not part of capturing the screen. The texture is held in the
From there, you need to copy the texture to a staging texture (use D3D11_USAGE_STAGING and D3D11_CPU_ACCESS_READ flags during texture creation) and then map the staging texture. You'll be able to access the bits after that. |
Hello @robmikh Sorry to bother. I have spent some time trying to figure it out based on your explanation. Can you look at the code see if am on the right track?
|
You're on the right track 🙂 Some things to consider:
D3D11_MAPPED_SUBRESOURCE mapped = {};
winrt::check_hresult(d3dContext->Map(bitmap.get(), 0, D3D11_MAP_READ, 0, &mapped));
std::vector<byte> bits(desc.Width * desc.Height * bytesPerPixel, 0);
auto source = reinterpret_cast<byte*>(mapped.pData);
auto dest = bits.data();
for (auto i = 0; i < (int)desc.Height; i++)
{
memcpy(dest, source, desc.Width * bytesPerPixel);
source += mapped.RowPitch;
dest += desc.Width * bytesPerPixel;
}
d3dContext->Unmap(bitmap.get(), 0); |
Thanks alot! 🙂 |
Hi @robmikh
One question: do you know how i can access the raw image data in order to encode it with FFMPEG? I assume this has to be done as soon as a new frame has arrived. Which will be in the function "OnFrameArrived". Do i get it from the backbuffer? Please guide me.
The text was updated successfully, but these errors were encountered: