【问题标题】:cmd command is not recognized as > an internal or external command, operable program or batch filecmd 命令未被识别为 > 内部或外部命令、可运行程序或批处理文件
【发布时间】:2015-11-30 09:39:05
【问题描述】:

当我运行这段代码时。

public void WaterMarkingUsingCommandLine(string videopath, string imagepath)
{
    string OutputFolder = AppDomain.CurrentDomain.BaseDirectory + "Output\\" + System.IO.Path.GetFileNameWithoutExtension(videopath) + "_Output.mp4";
    string ffmpegPath = @""""+AppDomain.CurrentDomain.BaseDirectory + @"ffmpeg.exe""";
    string ffmpegParams = @"-i """+videopath+@""" -i """+imagepath+@""" -filter_complex ""overlay=10:10"" """+OutputFolder+@"""";

    Process ffmpeg = new Process();
    ffmpeg.StartInfo.FileName = "cmd.exe";
    ffmpeg.StartInfo.Arguments = "/k " + ffmpegPath + " " + ffmpegParams;
    ffmpeg.Start();
}

我在 cmd 中看到了这个。

'c:\users\jafar.baltidynamolog\documents\visual' 未被识别为 内部或外部命令、可运行程序或批处理文件。

C:\Users\jafar.baltidynamolog\Videos\videos>

问题似乎是由空格引起的。正如其他问题中所说,我在文件名周围添加了逗号,但仍然无法正常工作。

更新

通过调试我发现了这个值

ffmpeg.StartInfo.Arguments=

"/k \"c:\users\jafar.baltidynamolog\documents\visual studio 2010\Projects\VideoProjectBilal\VideoProjectBilal\bin\Debug\ffmpeg.exe\" -i \"C:\Users\jafar.baltidynamolog\Videos\videos\SampleVideo_360x240_2mb.mp4\" -i \"C:\Users\jafar.baltidynamolog\Videos\images\2.png\" -filter_complex \"overlay=10:10\" \"c:\users\jafar.baltidynamolog\documents\visual studio 2010\Projects\VideoProjectBilal\VideoProjectBilal\bin\Debug\Output\SampleVideo_360x240_2mb_Output.mp4\""

【问题讨论】:

  • 请分享您在ffmpegPathffmpedParams 中获得的信息。您可能需要用双引号将 ffmpegPath 括起来。
  • 这不会解决你的问题,但可能不需要通过cmd /k 启动 - 你的StartInfo 的文件名应该是 ffmpeg.exe 的路径,并且应该更改参数相应地。

标签: c# cmd


【解决方案1】:

尝试更改此行:
string ffmpegPath = @""""+AppDomain.CurrentDomain.BaseDirectory + @"ffmpeg.exe""";
为此:
string ffmpegPath = @"""" + AppDomain.CurrentDomain.BaseDirectory + "ffmpeg.exe";

更新
试试这个:

string OutputFolder = AppDomain.CurrentDomain.BaseDirectory + "Output\\" + System.IO.Path.GetFileNameWithoutExtension(videopath) + "_Output.mp4";
string ffmpegPath =AppDomain.CurrentDomain.BaseDirectory + "ffmpeg.exe";
string ffmpegParams = "-i " + videopath + " -i " + imagepath + " -filter_complex overlay=10:10 " + OutputFolder ;

【讨论】:

    猜你喜欢
    • 2015-12-30
    • 2018-07-08
    • 2014-10-14
    • 2021-03-09
    • 2016-07-29
    • 1970-01-01
    • 2018-10-16
    • 2018-01-02
    相关资源
    最近更新 更多