Capturing Video using WinRT APIs on Windows 8 RRS feed

  • Question

  • I am writing native code in C++ to capture video on Windows 8 using WinRT API's.

    1. For video capturing I am trying to use IMFMediaSource ( OnReadSample callback to get the data)

       I have referred MFCaptureD3D and MFCaptureToFile sample which works on Windows 7.

       To enumerate the video capture device
       MFEnumDeviceSources is used in earlier versions of the windows.
       What is equvalent API in case of Windows 8 ?

    2. Meanwhile I came across MediaCapture class.
       In my case I need YUV data. Can I capture raw YUV data using MediaCapture class or
       It is only to capture encoded data?

       Please suggest which one I should use to capture raw YUV data from WebCam?   
       Thanks in advance.. Looking forward for the help

    Friday, October 5, 2012 8:54 AM


All replies

  • You can refer to the sample: Media capture using capture device sample and get the answer.
    1: function MediaCapture::AdvancedCapture::EnumerateWebcamsAsync() in AdvancedCapture.xaml.cpp
    2: As far as know, custom MFT is the only way to get YUV data. GrayscaleTransform in this sample is a good start.
    • Proposed as answer by moonincloud Friday, October 5, 2012 10:14 AM
    Friday, October 5, 2012 10:14 AM
  • Thanks for the reply.

    To understand correctly, you mean to say, we have to capture encoded data from the device and then convert it to desired YUV data format by custom MFT functions. I am worried about performance getting affected here.

    Is there any way to get raw YUV frames itself ??

    I can use IMFSourceReader to get raw frames but got stuck while enumerating the device (not able to find the equivalent function for MFEnumDeviceSources ).. Pls help...

    Friday, October 5, 2012 11:01 AM
  • Using custom MFT(Media Foundation transform) can get raw YUV frames. GrayscaleTransform is a custom MFT sample and can be found in "Media capture using capture device sample"
    MFEnumDeviceSources is no longer be supported in metro app, so you should use MediaCapture.
    If you want to pass some parameters to the MFT or get some information from it, you can refer to:
    • Proposed as answer by Jesse Jiang Monday, October 8, 2012 8:03 AM
    • Marked as answer by Jesse Jiang Tuesday, October 30, 2012 7:27 AM
    Friday, October 5, 2012 11:56 AM
  • Thanks for the help. I will go through the links..
    Friday, October 5, 2012 12:10 PM
  • Hi..

    Using custom MFT ( IMFTransform interface - setInputType,setOutputType,ProcessInput,ProcessOutput API's to get YUV frames from encoded frames ) is a redundant work for my project. Since I need to encode these YUV frames again with our optimized encoders before transmitting to network. Getting captured frames as encoded and decoding it to raw frames is extra work which can affect the overall performance. I am really interested to know why raw YUV frames capture is not supported in WinRT ? Please help me to understand.. 

    Tuesday, October 9, 2012 10:18 AM
  • Generally for capturing app, in ProcessInput function, you can get YUV data. It determined the format supported by your camera and what format you choose.

    Friday, October 12, 2012 5:26 AM
  • Hello,

    I know it's been a while since you posted that, but I also need raw frame (YUV) in Windows Phone 8.1 (RunTime, Universal App). How did you finally make it ?

    Did you use MFT driver, which can affect the performance especially on a Smartphone ? Or did you find another way ?

    Since Windows phone 8.1, many API are pretty much the same between Windows 8.1 and Windows Phone 8.1, so I guess you find it on Windows, it will be the same on the smartphone.


    Thursday, November 6, 2014 7:46 PM