Search code examples
imagecompressiondirectx-11desktop-duplication

Compression of raw resource data, of desktop image frame, from D3D11_MAPPED_SUBRESOURCE (Desktop Duplication API)


I need to transfer frames of desktop image data over the network, that were captured with Desktop Duplication API, but there is one problem: size of raw frame data, in FullHD with DXGI_FORMAT_B8G8R8A8_UNORM format, approximatly equal to 8 MB, that too large size, especially for one frame.

Is there something good method to compress the frame, of desktop image, data from D3D11_MAPPED_SUBRESOURCE and get the size at least in KB? Maybe some kind of conversion from bmp to jpeg?

I've already tried LZ4 compression, with LZ4_compress_default method, and got byte array with 3.4 MB size, that is still too much for frame.


Solution

  • ...large size, especially for one frame

    Since you are doing video and network transmission is in question, the only real choices for you are H.264 and H.265 video compression - those available implemented in hardware assisted encoders on video adapters. Microsoft Media Foundation API (Transforms) and video hardware vendor specific SDKs offer related functionality.

    Windows Imaging Component (WIC) for individual images will be both slower and less efficient in compression ratio. Although it could be a good choice in the case individual snapshots are the only data to transmit, as opposed to video.

    Also, an easy way to check out support for video encoding: http://alax.info/blog/1609

    The tools enumerates the transforms and provides details, similar to Enumerating Media Foundation Transforms (MFTs) application