gpt4 book ai didi

asp.net - 在 asp.net 中使用 ffmpeg

转载 作者:行者123 更新时间:2023-12-04 23:00:39 26 4
gpt4 key购买 nike

我需要一个音频转换库。在拉了我的头发之后..我已经放弃了没有这样的音频库的事实..那里的每个库都有一些或其他问题。

剩下的唯一选择是 ffmpeg,这是最好的,但不幸的是你不能在 asp.net 中使用它(我的意思不是直接)。网站上将转换文件的每个用户;将启动一个 exe?我想我很快就会达到服务器内存最大值。

底线:我将尝试使用 ffmpeg.exe 并查看它可以同时支持多少用户。

我去了 ffmpeg 网站,在 windows 下载部分找到了 3 个不同的版本;静态、共享和开发。

有谁知道哪个是最好的?全部打包在一个 exe(静态)或 dll 中,并且 exe 很小,wrt 在 asp.net 中使用它吗?

PS:任何人都有一个好的图书馆。如果你能分享,那就太好了。

静态构建为每个程序(ffmpeg、ffprobe、ffplay)提供一个独立的 .exe 文件。

共享构建将每个库提供为单独的 .dll 文件(avcodec、avdevice、avfilter 等),以及依赖于每个程序的这些库的 .exe 文件

开发包提供在其他程序中使用 .dll 文件所需的头文件和 .lib/.dll.a 文件。

最佳答案

ffMpeg 是我使用过的最好的库,但我不建议尝试直接从 asp.net 调用它。

我所做的是接受上传,将其存储在服务器上,或者在我的情况下存储在 S3 上,然后拥有一个工作角色(如果使用像 Azure 之类的东西)和一个持续查找和监视要转换的新文件的进程。

如果您需要类似实时的解决方案,您可以更新数据库中的标志并使用 AJAX 解决方案来轮询数据库以继续提供进度更新,然后在转换完成后提供下载链接。

就我个人而言,我的方法是

  • Azure Web 角色
  • Azure 辅助角色
  • 服务总线

  • WorkerRole 启动并正在监视 ServiceBus 队列中的消息。

    ASP.NET 站点将文件上传并存储在 S3 或 Azure 中
    然后,如果需要,ASP.NET 站点会在您的 DB 中记录信息,并向 ServiceBus 队列发送一条消息。

    WorkerRole 拾取并转换。

    如果您需要实时监控解决方案,ASP.NET 站点将需要 AJAX。否则,如果需要,您可以在完成时发送电子邮件。

    使用排队过程还可以帮助您减轻负载,因为当您承受重负载时,人们只需等待一段时间,它不会让所有事情都停止。您还可以根据需要扩展您的工作角色以平衡负载,如果它对于一台服务器来说变得太多的话。

    这是我从 C# 运行 ffMpeg 的方式(您需要根据需要更改参数)
    String params = string.Format("-i {0} -s 640x360 {1}", input.Path, "C:\\FilePath\\file.mp4");

    RunProcess(params);

    private string RunProcess(string Parameters)
    {
    //create a process info
    ProcessStartInfo oInfo = new ProcessStartInfo(this._ffExe, Parameters);
    oInfo.UseShellExecute = false;
    oInfo.CreateNoWindow = true;
    oInfo.RedirectStandardOutput = true;
    oInfo.RedirectStandardError = true;

    //Create the output and streamreader to get the output
    string output = null; StreamReader srOutput = null;

    //try the process
    try
    {
    //run the process
    Process proc = System.Diagnostics.Process.Start(oInfo);
    proc.ErrorDataReceived += new DataReceivedEventHandler(proc_ErrorDataReceived);
    proc.OutputDataReceived += new DataReceivedEventHandler(proc_OutputDataReceived);

    proc.BeginOutputReadLine();
    proc.BeginErrorReadLine();

    proc.WaitForExit();

    proc.Close();
    proc.Dispose();
    }
    catch (Exception)
    {
    // Capture Error
    }
    finally
    {
    //now, if we succeeded, close out the streamreader
    if (srOutput != null)
    {
    srOutput.Close();
    srOutput.Dispose();
    }
    }



    return output;
    }

    关于asp.net - 在 asp.net 中使用 ffmpeg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23184437/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com