locked
How to add video stabization effect to the source reader

    Question

  •  I am trying to write the following code adding video stabilization effect to the source reader. Does it make sense?

    ComPtr<IMFActivate> spActivate;

    LPCWSTR szActivatableClassId = WindowsGetStringRawBuffer((HSTRING)    Windows::Media::VideoEffects::VideoStabilization->Data(), nullptr);

    hr =MFCreateMediaExtensionActivate(szActivatableClassId, nullptr, IID_PPV_ARGS(&spActivate));

    ComPtr<IMFSourceReaderEx>spReaderEx=nullptr;

    m_spReader.Get()->QueryInterface(IID_IMFSourceReaderEx,&spReaderEx);

    spReaderEx->RemoveAllTransformsForStream(MF_SOURCE_READER_FIRST_VIDEO_STREAM);

    hr =spReaderEx->AddTransformForStream(MF_SOURCE_READER_FIRST_VIDEO_STREAM,(IUnknown *)spActivate.Get());


    Monday, September 10, 2012 5:52 AM

Answers

  • Yes, you should be able to pass the IMFActivate interface to AddTransformForStream. You should never need to call RemoveAllTransformsForStream. Are you having a specific problem with this? Keep in mind that the Source Reader does not use the MF session manager like the Media Engine does. Because of this it is much more difficult to manipulate the underlying "topology".

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, September 18, 2012 12:09 AM
    Moderator

All replies

  • You must use one of the following APIs to create the source reader:

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Monday, September 10, 2012 10:56 PM
    Moderator
  • I have used MFCreateSourceReaderFromByteStream API creating source reader, it is m_spReader, and 

    hr =spReaderEx->AddTransformForStream(MF_SOURCE_READER_FIRST_VIDEO_STREAM,(IUnknown *)spActivate.Get());

    will fail,  but I have seen the sample code for IMFMediaEngine, it can using the following code to add video stablization,

    I want to know whether source reader can do this?

    ComPtr<IMFActivate> spActivate;   

    LPCWSTR szActivatableClassId = WindowsGetStringRawBuffer((HSTRING)Windows::Media::VideoEffects::VideoStabilization->Data(), nullptr);

    MEDIA::ThrowIfFailed(MFCreateMediaExtensionActivate(szActivatableClassId, nullptr, IID_PPV_ARGS(&spActivate)));

    MEDIA::ThrowIfFailed(m_spEngineEx->InsertVideoEffect(spActivate.Get(), FALSE));

    Tuesday, September 11, 2012 2:28 AM
  • Yes, you should be able to pass the IMFActivate interface to AddTransformForStream. You should never need to call RemoveAllTransformsForStream. Are you having a specific problem with this? Keep in mind that the Source Reader does not use the MF session manager like the Media Engine does. Because of this it is much more difficult to manipulate the underlying "topology".

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, September 18, 2012 12:09 AM
    Moderator
  • Thank you very much, After I delete the RemoveAllTransformsForStream function, it can work, thank you very much
    Thursday, September 20, 2012 6:32 AM