Hardi_Liang on Fri, 06 Apr 2012 06:49:52
I have found TransferVideoFrame() in Media engine native C++ playback sample
I want to use it to get the decoded data. My input is a mp4 or wmv file.
I am a newby for DirectX
Jesse Jiang on Mon, 09 Apr 2012 08:10:00
I would suggest you to follow this sample code to using Media Engine.
JohnYe on Tue, 10 Apr 2012 03:17:24
I have added capture a frame function in ME sample, to capture a bitmap from d3d surface after transfervideoframe. it works like this:
1) create ID2D1factory1, and then CreateDevice;
2) get dxgisurface from swapchain, like this: m_spDX11SwapChain->GetBuffer(0, IID_PPV_ARGS(&dxgiBackBuffer))
3) create bitmap from dxgisurface. like this: m_d2dContext->CreateBitmapFromDxgiSurface
4) save bitmap to file.
4.1) get a IRandomAccessStream from a file, get Istream from it via system api: CreateStreamOverRandomAccessStream
4.2) create IWICBitmapEncoder, Initialize it from this Istream.
4.3) create IWICImageEncoder, call IWICImageEncoder->WriteFrame to transfer d2dbitmap what we got before to Istream .
4.4) IWICImageEncoder::commit, IWICBitmapEncoder::commmit, Istream::commit
5) that's all.
surely, if you want to transfer video frame to image source and render it by yourself, it's another case.
I have tried solution before consume preview, and it crashed always on my PC.
as I got Media engine sample source code from consume previw, I didn't try it again, just apply DXGI manager to media engine and render with d3d device is fine for me.