如何使用"FFmpeg"在Azure上使用C#? [英] How to use "FFmpeg" with c# on Azure?

查看:76
本文介绍了如何使用"FFmpeg"在Azure上使用C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Azure上的Webjob减少mp4视频的大小.我的webjob中有一个队列触发器,每次添加新视频时,VideoCompressor Webjob都会将mp4视频文件的大小减小(根据方向+裁切,减小到200px的宽度或高度,只有2分钟).

根据我在互联网上阅读的内容,ffmpeg就是答案.有nuget包:FFmpeg.stable.GZCR.我想使用块状软件包,不必去ffmpeg网站并每次都验证是否有新版本.

但是我找不到有关它的任何文档:

我找到了一些有关FFmpeg的信息,但它是针对WinRT的,因此对我而言没有用:

  • 您有什么想法或建议吗?

    解决方案

    FFMPEG具有非常复杂的API,最好直接从C#程序调用该工具.在研究如何在ffmpeg中执行某些操作时,每个人都将就直接访问.exe来讨论该工具,因此与尝试使用包装器API相比,您将避免混乱.

    例如,您可以使用 System.Diagnostics.Process 进行此操作

      var process = new Process{//ffmpeg二进制文件的路径FileName ="ffmpeg.exe",//示例ffmpeg命令从mp4视频中获取声音参数="-i input.mp4 -vn -ab 320 output.mp3",UseShellExecute =假}process.Start(); 

    如果要自动升级ffmpeg,可以编写脚本以从GitHub存储库中获取最新版本,然后自己编译ffmpeg.

    I would like to reduce the size of a mp4 video from a webjob on Azure. I have a queue trigger in my webjob, each time a new video is added, the VideoCompressor Webjob will reduce the size of the mp4 video file (reduce to 200px width or height depending of the orientation + crop to only 2 min).

    From what I read on internet, ffmpeg is the answer. There is nuget package: FFmpeg.stable.GZCR. I would like to use a nugget package to not have to go on the ffmpeg website and verify each time if there a new version.

    But I don't find any documentation about it:

    I found some information about FFmpeg but it's for WinRT, so not usefull in my case:

    I found this code, it seems to be what I would like to do. The problem is from the nugget package, I dont know how to access to the ffmpeg.exe", but maybe you have other idea?

    Do you have any idea or suggestion?

    解决方案

    FFMPEG has a very complex API and you may be better off calling the tool directly from a C# program. When researching how to do something in ffmpeg everyone will be discussing the tool in terms of accessing the .exe directly so you will have less confusion than attempting to use a wrapper API.

    You can do this using System.Diagnostics.Process, for example

    var process = new Process
    {
        // Path to your ffmpeg binary
        FileName = "ffmpeg.exe",
        // Example ffmpeg command to get the sound from an mp4 video
        Arguments = "-i input.mp4 -vn -ab 320 output.mp3",
        UseShellExecute = false
    }
    
    process.Start();
    

    If you want to automate upgrading ffmpeg you could script it to get the latest release from the GitHub repository and compile ffmpeg yourself.

    这篇关于如何使用"FFmpeg"在Azure上使用C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆