'Copy raw video frame buffer to IDirect3DSurface
Normally, MediaPlayer has supported function CopyFrameToVideoSurface(IDirect3DSurface destination) to copy video frame to Direct3DSurface.
But now I receive a video frame as byte[] pbuffer with width and Height, how do I transfer it to IDirect3DSurface like MediaPlayer did?
Thanks
Edit: To render video frame of MediaPlayer, I use:
public void VideoFrameAvailable(Windows.Media.Playback.MediaPlayer sender, object args)
{
var swapChain = _swapChain.Object;
using var dxgiSurface = swapChain.GetBuffer<IDXGISurface>(0);
var dxgiSurfacePtr = Marshal.GetComInterfaceForObject<IDXGISurface, IDXGISurface>(dxgiSurface.Object);
CreateDirect3D11SurfaceFromDXGISurface(dxgiSurfacePtr, out var graphicsSurface).ThrowOnError();
Marshal.Release(dxgiSurfacePtr);
using var d3DSurface = MarshalInterface<IDirect3DSurface>.FromAbi(graphicsSurface)!;
Marshal.Release(graphicsSurface);
sender.CopyFrameToVideoSurface(d3DSurface);
swapChain.Present(1, 0).ThrowOnError();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
