none
How to save a bitmap raw data by using TransferVideoFrame()

Alle Antworten

  • Hello,

    I would suggest you to follow this sample code to using Media Engine.
    http://code.msdn.microsoft.com/windowsapps/Media-Engine-Playback-ce1c82f0/

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Montag, 9. April 2012 08:10
    Moderator
  • hi, hardi:

    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.


    ---------------------------------------------- JohnYe from SHANGHAI. email: yechzh@126.com

    Dienstag, 10. April 2012 03:17