ffmpeg无法识别

时间:2014-12-23 18:25:57

标签: c# visual-studio-2013 ffmpeg

以下代码在CMD窗口中给出了一个错误(Visual Studio 2013 - c #project): ' FFMPEG'不被视为内部或外部命令

Process p = new Process();
        ProcessStartInfo info = new ProcessStartInfo();
        info.FileName = "cmd.exe";
        info.RedirectStandardInput = true;
        info.UseShellExecute = false;

        p.StartInfo = info;
        p.Start();

        using (StreamWriter sw = p.StandardInput)
        {
            if (sw.BaseStream.CanWrite)
            {
                sw.WriteLine("ffmpeg -i test.mp4 test.mp3");
                //    sw.WriteLine("mypassword");
                //    sw.WriteLine("use mydb;");
            }
        }

只有在我运行命令" ffmpeg -i test.mp4 test.mp3"从代码。另一种方式是运行 - 直接从CMD运行命令..任何建议,使其工作从代码?

1 个答案:

答案 0 :(得分:2)

使用WorkingDirectory属性设置ffmpeg可执行文件的位置。

info.WorkingDirectory = @"C:\myFFMPEGDir";

目前,它正在尝试查看与ffmpeg的流程相同的目录。听起来ffmpeg不存在,所以你需要设置路径。

或者,您可以在命令中编写整个路径。

sw.WriteLine("C:\\myFFMPEGDir\\ffmpeg.exe -i test.mp4 test.mp3");
相关问题