【问题标题】:Qt WinRT App cannot access file permission deniedQt WinRT App 无法访问文件权限被拒绝
【发布时间】:2016-02-23 16:51:36
【问题描述】:

我需要使用 Qt 和 FFMPEG 开发 WinRT 应用程序,我根据指令 here 为 WinRT 构建 ffmpeg,并且我能够将库与我的项目链接。现在我需要使用avformat_open_input 打开一个视频文件,但它总是给我输出

video decode error "Permission denied"

下面是相关部分的代码,

 int ret = avformat_open_input(&pFormatCtx, hls, NULL, NULL);
    if(ret != 0)
    {
        char errbuf[128];
        av_strerror(ret, errbuf, 128);
        qDebug()<<"video decode error"<<QString::fromLatin1(errbuf);

    }

从上面的错误来看,似乎是一些权限问题,我是否需要在AppxManifest.xml 上添加任何额外的权限,目前我正在使用由 Qt 创建者创建的默认清单。

【问题讨论】:

    标签: qt ffmpeg windows-runtime


    【解决方案1】:

    尝试将文件协议添加到清单页面,包含您想要访问/创建或使用的文件扩展名..

    例如,.xml、.txt、.etc..

    在不添加 ext 文件协议的情况下尝试访问文件时,我总是遇到这个“未知”错误。

    更新: 更多信息:https://msdn.microsoft.com/library/windows/apps/hh464906.aspx#file_activation

    通过:Package.appxmanifest > 声明 > 添加“文件类型关联” > 您的类型名称和分机。是必需的。

    代码中的示例:

      <Extensions>
        <uap:Extension Category="windows.fileTypeAssociation">
          <uap:FileTypeAssociation Name="myfile">
            <uap:SupportedFileTypes>
              <uap:FileType>.config</uap:FileType>
            </uap:SupportedFileTypes>
          </uap:FileTypeAssociation>
        </uap:Extension>
      </Extensions> 
    

    更改“我的文件”和“.config”

    祝你好运!

    【讨论】:

    • 谢谢你的回答,能不能给我参考一下。
    • 我添加了下面的代码` DisplayName .mp4` 在清单文件上,但仍然是错误Failed to get file URI. (Access is denied.)
    • 您是否尝试访问系统文件夹?像视频库或文档文件夹?您需要 Appxmanifest 中的权限(在功能中检查)
    • 我尝试通过添加 &lt;Capabilities&gt; &lt;Capability Name="musicLibrary" /&gt; &lt;Capability Name="internetClient" /&gt; &lt;Capability Name="videosLibrary" /&gt; &lt;Capability Name="picturesLibrary" /&gt; &lt;/Capabilities&gt; ,基本上我的应用程序所做的是,用户可以选择通过浏览选择视频文件,然后应用程序应该播放该文件。实际上,为了确定是否是权限问题,我编写了简单的代码来创建一个也给出了一些错误的目录,我在这里发布了问题stackoverflow.com/questions/35560994/…
    猜你喜欢
    • 2016-01-31
    • 1970-01-01
    • 2014-08-10
    • 1970-01-01
    • 2014-03-16
    • 2021-09-16
    • 2013-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多