c# - 是否可以在共享托管服务器中使用 `ffmpeg.exe`?

标签 c# asp.net ffmpeg

关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。












这个问题似乎是题外话,因为它缺乏足够的信息来诊断问题。更详细地描述您的问题或include a minimal example在问题本身。


8年前关闭。







Improve this question




我用 ffmpeg.exe将视频文件转换为 flv但它不适用于共享主机。
是否可以使用 ffmpeg在共享主机中?
这是我的代码:

 private bool ReturnVideo(string fileName)
    {
        string html = string.Empty;
        //rename if file already exists

        int j = 0;
        string AppPath;
        string inputPath;
        string outputPath;
        string imgpath;
        AppPath = Request.PhysicalApplicationPath;
        //Get the application path
        inputPath = AppPath + "OriginalVideo";
        //Path of the original file
        outputPath = AppPath + "ConvertVideo";
        //Path of the converted file
        imgpath = AppPath + "Thumbs";
        //Path of the preview file
        string filepath = Server.MapPath("~/OriginalVideo/" + fileName);
        while (File.Exists(filepath))
        {
            j = j + 1;
            int dotPos = fileName.LastIndexOf(".");
            string namewithoutext = fileName.Substring(0, dotPos);
            string ext = fileName.Substring(dotPos + 1);
            fileName = namewithoutext + j + "." + ext;
            filepath = Server.MapPath("~/OriginalVideo/" + fileName);
        }
            this.fileuploadImageVideo.SaveAs(filepath);
        string outPutFile;
        outPutFile = "~/OriginalVideo/" + fileName;
        int i = this.fileuploadImageVideo.PostedFile.ContentLength;
        System.IO.FileInfo a = new System.IO.FileInfo(Server.MapPath(outPutFile));
        while (a.Exists == false)
        {

        }
        long b = a.Length;
        while (i != b)
        {

        }


        string cmd = " -i \"" + inputPath + "\\" + fileName + "\" \"" + outputPath + "\\" + fileName.Remove(fileName.IndexOf(".")) + ".flv" + "\"";
        ConvertNow(cmd);
        string imgargs = " -i \"" + outputPath + "\\" + fileName.Remove(fileName.IndexOf(".")) + ".flv" + "\" -f image2 -ss 1 -vframes 1 -s 280x200 -an \"" + imgpath + "\\" + fileName.Remove(fileName.IndexOf(".")) + ".jpg" + "\"";
        ConvertNow(imgargs);


        return true;
    }
    private void ConvertNow(string cmd)
    {
        string exepath;
        string AppPath = Request.PhysicalApplicationPath;
        //Get the application path
        exepath = AppPath + "ffmpeg.exe";
        System.Diagnostics.Process proc = new System.Diagnostics.Process();
        proc.StartInfo.FileName = exepath;
        //Path of exe that will be executed, only for "filebuffer" it will be "flvtool2.exe"
        proc.StartInfo.Arguments = cmd;
        //The command which will be executed
        proc.StartInfo.UseShellExecute = false;
        proc.StartInfo.CreateNoWindow = true;
        proc.StartInfo.RedirectStandardOutput = false;
        proc.Start();

        while (proc.HasExited == false)
        {

        }
    }

最佳答案

您不能实例化 System.Diagnostics.Process对象,除非您在 FullTrust 上运行。

This class contains a link demand and an inheritance demand at the class level that applies to all members. A SecurityException is thrown when either the immediate caller or the derived class does not have full-trust permission.



通常托管服务提供商不允许共享主机上的应用程序在完全信任下运行。有关更多详细信息,请联系您的支持人员,或者只是在服务器上运行您的代码。

要更改信任级别,请在 web.config 中设置
<trust level="Full" originUrl=""/>

关于c# - 是否可以在共享托管服务器中使用 `ffmpeg.exe`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23724657/

相关文章:

.net - 从ASP.net控件中删除onblur验证

c# - 自动将 Interface<T> 解析为 StructureMap 中的 Implementation<T>(仅泛型类型 T 不同)

c# - RavenDB 获取查询不起作用的总计数

c# - Null Check Operator 仍然返回空值

c# - LINQ 查询中的三元运算符

c# - 如何将 NameValueCollection 转换为 JSON 字符串?

iphone - iphone sdk中的ffmpeg问题?

macos - 将bash中带有空格的文件名脚本变量传递给外部程序(ffmpeg)失败

ffmpeg - 通过搜索流式传输 MKV

c# - 将 sql 语句的结果存储到字符串中,并将其与列表框中选择的项目进行比较