简体   繁体   English

WMEncoder引发COMException(0x80004005)未指定的错误

[英]WMEncoder Throws COMException (0x80004005) Unspecified Error

So I'm running this code 所以我正在运行这段代码

    public static void ConvertToWma(string inFile, string outFile, string profileName)
    {
        // Create a WMEncoder object.
        WMEncoder encoder = new WMEncoder();
        ManualResetEvent stopped = new ManualResetEvent(false);
        encoder.OnStateChange += delegate(WMENC_ENCODER_STATE enumState)
        {
            if (enumState == WMENC_ENCODER_STATE.WMENC_ENCODER_STOPPED)
                stopped.Set();
        };
        // Retrieve the source group collection.
        IWMEncSourceGroupCollection srcGrpColl = encoder.SourceGroupCollection;

        // Add a source group to the collection.
        IWMEncSourceGroup srcGrp = srcGrpColl.Add("SG_1");

        // Add an audio source to the source group.
        IWMEncSource srcAud = srcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
        srcAud.SetInput(inFile, "", "");

        // Specify a file object in which to save encoded content.
        IWMEncFile file = encoder.File;
        file.LocalFileName = outFile;

        // Choose a profile from the collection.
        IWMEncProfileCollection proColl = encoder.ProfileCollection;
        proColl.ProfileDirectory = AssemblyInformation.GetExecutingAssemblyDirectory();
        proColl.Refresh();
        IWMEncProfile pro;

        for (int i = 0; i < proColl.Count; i++)
        {
            pro = proColl.Item(i);
            if (pro.Name == profileName)
            {
                srcGrp.set_Profile(pro);
                break;
            }
        }
        // Start the encoding process.
        // Wait until the encoding process stops before exiting the application.
        encoder.SynchronizeOperation = false;
        encoder.PrepareToEncode(true);
        encoder.Start();
        stopped.WaitOne();
    }

And I get a COMException (0x80004005) when encoder.PrepareToEncode gets executed. 我在执行encoder.PrepareToEncode时收到COMException(0x80004005)。

Some notes: 一些注意事项:

1) The process is spawned by an ASP.NET web service so it runs as NETWORK SERVICE 2) inFile and outFile are absolute local paths and their extensions are correct, in addition inFile definitely exists (this has been a source of problems in the past) 3) The program works when I run it as myself but doesn't work in the ASP.NET context. 1)该过程由ASP.NET Web服务生成,因此它作为NETWORK SERVICE运行。2)inFile和outFile是绝对本地路径,并且它们的扩展名正确,此外inFile确实存在(这过去是问题的根源) )3)该程序在我自己运行时可以运行,但是不能在ASP.NET上下文中运行。

This says to me its a security permission issue so in addition I've granted Full Control to the directory containing the program AND the directories containing the audio files to NETWORK SERVICE. 这对我来说是一个安全许可问题,因此我还对包含程序的目录和包含音频文件的目录授予了“完全控制”权限,以便网络服务。 So I really don't have any idea what more I can do on the security front. 所以我真的不知道我在安全方面还能做些什么。 Any help? 有什么帮助吗?

Running WM Encoder SDK based app in windows service is not supported. 不支持在Windows Service中运行基于WM Encoder SDK的应用程序。 It uses hidden windows for various reasons, and there isn't a desktop window in service. 由于各种原因,它使用隐藏的窗口,并且服务中没有桌面窗口。 DRM would certainly fail with no user profile. 没有用户配置文件,DRM当然会失败。 Besides, even when you make your service talk to WME instance on a user's desktop, Microsoft only supports 4 concurrent requests per machine because the global lock in WME (I know, not pretty programming, but WME is old). 此外,即使您使服务与用户桌面上的WME实例进行通信,Microsoft也仅支持每台计算机4个并发请求,因为WME中的全局锁定(我知道,编程不是很漂亮,但是WME很旧)。 For more scalable solutions, consider Windows Media Format SDK. 有关更可扩展的解决方案,请考虑使用Windows Media Format SDK。

You may want to move your WM Encoder based app to Expression Encoder SDK as WM Encoder's support is ending. 随着WM Encoder的支持终止,您可能需要将基于WM Encoder的应用程序移动到Expression Encoder SDK。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.Data.OleDb.OleDbException(0x80004005):未指定的错误 - System.Data.OleDb.OleDbException(0x80004005): Unspecified Error UWP:未指定的错误 - 来自 HRESULT 的异常:0x80004005 - UWP: Unspecified Error - Exception from HRESULT: 0x80004005 OLEDB Oracle未指定错误(E_FAIL(0x80004005))查询 - OLEDB Oracle Unspecified Error(E_FAIL(0x80004005)) on query Visual Studio 2013>新项目>未指定的错误(来自hresult的异常:0x80004005(e_fail)) - Visual Studio 2013 > New project > unspecified error (exception from hresult: 0x80004005 (e_fail)) AutoDesk Forge Inventor - 未指定错误(HRESULT 异常:0x80004005 (E_FAIL)) - AutoDesk Forge Inventor - Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)) 未指定的错误(HRESULT的异常:0x80004005(E_FAIL))(Web服务) - Unspecified error (Exception from HRESULT: 0x80004005(E_FAIL)) (Web Service) OleDbException(0x80004005):未指定错误? - OleDbException (0x80004005): Not specified error? TCPClient套接字错误0x80004005的原因 - Causes of TCPClient socket error 0x80004005 ExternalException (0x80004005) GDI+ 中发生一般错误 - ExternalException (0x80004005) A generic error occurred in GDI+ 错误! mysql.data.mysqlclient.mysqlexception(0x80004005) - Error! mysql.data.mysqlclient.mysqlexception(0x80004005)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM