Problems with Media Foundation in windows 8 App RRS feed

  • Question

  • Hi

    I am trying to create an app using Media Foundation. First I developed via c++ and tested it as normal app and it worked fine. When I tried same code (with the changes that are necessary for windows 8 app) it gave access violation exception.

    HRESULT hr = MFCreateSinkWriterFromURL((WCHAR *)(location->Data()), NULL, NULL, &pSinkWriter);

    Here location is Platform::String.

    Then instead of location I used the following code.

    HRESULT hr = MFCreateMFByteStreamOnStreamEx((IUnknown*)stream, &spByteStream);

    hr = MFCreateSinkWriterFromURL(L".wmv", spByteStream, NULL, &pSinkWriter);

    Now the program worked without any exception however the time taken by program to create 15 sec video is more than 3 minutes. If I run it in desktop app then it takes less than 30 seconds.

    Why so much difference in same code when you run it on different platform?

    I referenced the below url and other works and samples provided by microsoft.


    So is there any way I can make it much faster...? Or use string based location instead of stream.?

    • Edited by Ajit7832 Tuesday, December 9, 2014 3:41 PM
    Tuesday, December 9, 2014 3:37 PM

All replies

  • Hi Ajit7832,

    May I know what is your location? Access violation exception looks like the path you are using is not correct. I would recommend you to follow the documentation: File access and permissions to validate if your file access is valid.

    However I don't know if you test the second method in a Desktop app, the method can either creates the sink writer from a URL or byte stream, the first one might take less time and second one might take longer time because you have one more step to read data into byte stream.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Jamles HezModerator Wednesday, December 17, 2014 7:29 AM
    • Unmarked as answer by Ajit7832 Wednesday, December 17, 2014 12:38 PM
    Wednesday, December 10, 2014 7:33 AM
  • The location is document folder. If I tried to pass it as string or url it will give error. 

    var spicker = new FileSavePicker();
    spicker.FileTypeChoices.Add("Video Files", new[] { ".wmv" }.ToList());
    var vidfile = await spicker.PickSaveFileAsync();
    if (vidfile == null)
             return "";
    //If I used the vidfile.path it wont work. So here I need to use stream.
    var vstream = await vidfile.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);

    If I used a stream it will work. However during sinkwriter->finalize() method  takes too much time.


    Wednesday, December 17, 2014 12:43 PM