Getting Video frames using MediaCapture class and custom sink RRS feed

  • Question

  • Hi,

    I am trying to use MediaCapture class to get video frames. There is no API to get video frames directly.

    I got to know that I should use StartRecordToCustomSinkAsync function. Can anybody give sample code on how to implement this?

    If I give custom sink as second parameter to the above API, which API is going to give me frames? (Is it ProcessSample ? )

    Do I need implement another custom class IMFStreamSink, ProcessSample of IMFStreamSink will give IMFSample?

    Who calls ProcessSample ? Is it media pipeline?

    Do I need to implement all the functions of IMFMediaSink and IMFStreamSink ? or Is there any simple way to get frames?

    Thanks in advance for any help!

    Wednesday, October 17, 2012 1:03 PM

All replies

  • Hi,

    How about this sample codes?
    Media capture using capture device sample

    Best regards,

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

    Friday, October 19, 2012 7:41 AM
  • Hi,

    Thanks a lot for your reply.

    I have referred this sample. But this sample has StartRecordToStorageFile function which writes recorded data to storage file.

    But I need video frames from the webcam. For this I need to use StartRecordToCustomSinkAsync function and write custom media sink.

    I dont have a sample for the above API. I have a simple doubt that how to connect capture source to the media sink and how do I get video frames in sink ?



    Friday, October 19, 2012 7:50 AM
  • Hi,

    I also want to write a custom sink to use StartPreviewToCustomSinkAsync(MediaEncodingProfile, IMediaExtension) of MediaCature Api. 

    Is there any sample ?
    Thursday, May 23, 2013 6:54 PM
  •  The IMediaExtension instance must implement the IMFMediaSink interface. Here is how to declare such a class:

    class CGetSamples WrlSealed
    	: public RuntimeClass<
    	RuntimeClassFlags< Microsoft::WRL::RuntimeClassType::WinRtClassicComMix >,

    Then the problem just comes down to creating an instance of this custom sink to pass to the StartRecordToCustomSinkAsync function.  That doesn't have to be in a .dll and doesn't have to be created by name.  It can be part of your app code.

    IInspectable* pInstpectable = nullptr;
    HRESULT hr = MakeAndInitialize<CGetSamples>(&pInstpectable);
    IMediaExtension^ me = reinterpret_cast<IMediaExtension^>(pInstpectable);
    // m_MC is an instance of MediaCapture
    MediaEncodingProfile^ mep = MediaEncodingProfile::CreateMp4(VideoEncodingQuality::Vga);
    m_MC->StartRecordToCustomSinkAsync(mep, me);
    Tuesday, April 15, 2014 3:38 AM