Menu

Access Denied Error in MFCaptureAlt sample

2015-08-25
2015-08-27
  • Brian Hanline

    Brian Hanline - 2015-08-25

    I just downloaded Media Foundation .NET along with the samples. I built the MFCaptureAlt sample and executed on my tablet. When I select a camera, the sample throws a COM exception: -2147024891 - Access Denied.

    Since I'm totally new to this, I'm sure its something I did. Can anyone help?

    I'm running: Windows 8.1. I compiled the sample in Visual Studio 2013.

    Question: Do I need to "install" the MediaFoundation.dll somehow? I simply made a reference to it from the sample application.

    Question: Can I assume Microsoft Media Foundation is already installed and available on my Windows 8.1 tablet?

    Thanks,

    Brian

     
    • snarfle

      snarfle - 2015-08-26

      What line is throwing the exception? It wouldn't happen to be trying to load c:\lgs.jpg and not finding it?

       
  • Brian Hanline

    Brian Hanline - 2015-08-26

    It is line 86 in WinMain. Please see attached screen print It appears to be setting the selected device.

    I select a camera from the drop down and hit OK. Line 85 calls m_pPreview.SetDevice() with the selected device. That call returns a negative value. On line 86, MFError sees the negative return code and throws the exception.

    Note that I am running visual studio on my desktop and remotely debugging on the tablet. But, the same error is thrown when I run locally on the tablet.

    Thanks for repsonding so quickly.

    Brian

     
  • Brian Hanline

    Brian Hanline - 2015-08-26

    UPDATE: I've traced it further into class CPreview. The line that causes hr to turn negative is 237 in CPreview.cs:

            int hr = MFExtern.MFCreateSinkWriterFromURL(
                OutputFileName,
                null,
                null,
                out m_pWriter
                );
    

    That line returns -2147024891.

     
  • Brian Hanline

    Brian Hanline - 2015-08-26

    UPDATE: Sorry for the running comentary but...

    OutputFileName and BitmapOverlayFile are hardcoded in class CPreview. It appears that access is denied for c:\foo.mp4. Probably because this file does not exist. But, if it did, it would fail again on lgs.jpg which also doesn't exist. I'm guessing that lgs.jpg is the watermark to be overlayed on the capture which is the point of this sample project?

        private const string OutputFileName = @"c:\foo.mp4";
        private const string BitmapOverlayFile = @"c:\lgs.jpg";
    

    I can probably get this running but any comments you have will be appreciated. But this leads to a more important question:

    My goal here is to create a simple camera application. I just want to preview the video feed and capture a snapshot from it. I do not want to save the video feed to a file. I do need to be able to set the resolution of the camera to the highest possible setting. Is there a sample app that acheives this which can get me started?

    Thanks,

    Brian.

     
  • Eric

    Eric - 2015-08-27

    Change the path "c:\" to another folder where you have read-write rights.

    By default, only Administrators can write at the root of the C drive and if UAC is activated this right is denied even if you are Administrators.

     

Log in to post a comment.