How to get the raw data from device camera?


  • Hi,

    We are developing a Windows 8.1 and Windows Phone 8.1 (WinRT) applications. We need to read the RAW video data from the device's camera, so we can process the video data.

    What would be the recommended way to do it?


    Wednesday, October 22, 2014 11:05 PM

All replies

  • Hi eitanb,

    Read raw video data from device camera? How about this? We can get some video raw data from VideoEncodingProperties class

            System.Collections.Generic.IReadOnlyList<IMediaEncodingProperties> res;
            res = this.mediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview);
            uint maxResolution = 0;
            int indexMaxResolution = 0;
            if (res.Count >= 1)
                for (int i = 0; i < res.Count; i++)
                    VideoEncodingProperties vp = (VideoEncodingProperties)res[i];


    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, October 23, 2014 7:42 AM
  • Hi Jamles,

    Thanks for your answer. However I need to do some image tracking and I don't think I can do it on the properties :)

    Any way to get the "real" data stream?


    Thursday, October 23, 2014 3:37 PM
  • You'll need to write an MFT in C++ to access the live data stream.

    This is demonstrated in the Media extensions sample 

    Thursday, October 23, 2014 3:50 PM
  • Hi Rob, Looked at the Media Extensions Sample. This sample "takes" a Video file that already exists on the computer, and then manipulate it. What I need is to read the Video stream data directly from the device own camera feed (either WP8.1 or W8.1 devices). Hope you can lead me in the right direction, thanks, Eitan
    Thursday, October 23, 2014 5:46 PM
  • Same idea, but you'll call MediaCapture.StartRecordToCustomSinkAsync to record through your Media Extension.

    The Real-time communication sample has a demonstration.


    Thursday, October 23, 2014 7:21 PM
  • Hi Rob,

    I looked at the Real-Time Communication sample. This example uses and implements StspMediaSinkProxy as the mediaSink.

    Will I have to implement my own mediaSink?
    Are the frames are coming at a certain format (e.g. YUV, RGB24 etc.)?

    Again, I am trying to get the phone camera raw video feed stream.


    • Edited by eitanb Saturday, October 25, 2014 7:29 AM better explanation
    Thursday, October 23, 2014 10:06 PM
  • Hi Rob,

    Any update on my question?


    Wednesday, October 29, 2014 5:03 PM
  • Yes. You'll have to write your own (or find one somebody else has written that does what you need)
    Wednesday, October 29, 2014 10:25 PM
  • Anywhere I can find a walkthrough or any other documentation how to write my own Custom Media Sink??


    Thursday, October 30, 2014 5:24 PM
  • I'm not aware of anything beyond the already linked samples.
    Thursday, October 30, 2014 11:22 PM
  • This sample demonstrates how to use the MediaCapture API to capture video, audio, and pictures from a capture device, such as a webcam.

    Specifically, this sample covers:

    • Previewing video from a capture device, such as a webcam, connected to the computer.
    • Capturing video from a capture device, such as a webcam, connected to the computer.
    • Taking a picture from a capture device, such as a webcam, connected to the computer.
    • Enumerating cameras connected to the computer.
    • Adding a video effect to a video.
    • Recording audio from a capture device connected to the computer.

    This sample has been updated for Windows 8.1. It now shows how to use the following new media capture features:

    For more information on capturing video in your app, see Quickstart: capturing a photo or video using the camera dialog and Quickstart: capturing video using the MediaCapture API.

    You may get the reference from https://code.msdn.microsoft.com/windowsapps/Media-Capture-Sample-adf87622

    Monday, November 3, 2014 7:30 AM
  • Thank you for the summary.

    I am very familiar with these samples. However, they do not show access to the RAW data as it comes from the phone video camera.


    Monday, November 3, 2014 4:20 PM