简体   繁体   English

C#和ffpmeg命令行问题

[英]c# and ffpmeg command line trouble

I have a php code that calls ffmpeg from the windows command line (because I run apache locally) with: 我有一个从Windows命令行调用ffmpeg的php代码(因为我在本地运行apache),它具有:

//ffmpeg -i input.mp4 -r 20 output.gif
        echo exec('C:\ffmpeg\bin\ffmpeg.exe -i videos/file.avi -r 10  -s 450x230 videos/file.gif');

And it works fine! 它工作正常! Now I wrote a C# program and I try to do the same thing with: 现在,我编写了一个C#程序,并尝试使用以下方法执行相同的操作:

 System.Diagnostics.Process.Start

but it fails. 但是失败了。

Question: How do I execute the same command from the PHP code but from inside a C# code? 问题:如何从PHP代码但从C#代码内部执行同一命令?

Process process = Process.Start(
    new ProcessStartInfo
    {
        FileName = @"C:\ffmpeg\bin\ffmpeg.exe",
        Arguments = "-i videos/file.avi -r 10  -s 450x230 videos/file.gif",
        WindowStyle = ProcessWindowStyle.Hidden
    }
);
process.WaitForExit();

If it fails an exception will be raised, eg System.ComponentModel.Win32Exception with HResult=-2147467259 if the executable wasn't found. 如果失败,将引发异常,例如,如果未找到可执行文件,则System.ComponentModel.Win32Exception的HResult = -2147467259。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM