本文介绍了运行外部程序(ffmpeg)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 以下是我正在使用的代码: private string ConvertVideoFiles ( string strCommandLineSwitches) {处理prcExecuteFFMPEG = 新 Process(); prcExecuteFFMPEG.StartInfo.FileName = @ c:\ windows \ system32 \ cmd.exe ; // prcExecuteFFMPEG.StartInfo.WorkingDirectory = @C:\; prcExecuteFFMPEG.StartInfo.Arguments = strCommandLineSwitches; prcExecuteFFMPEG.StartInfo.UseShellExecute = false ; prcExecuteFFMPEG.StartInfo.RedirectStandardOutput = true ; prcExecuteFFMPEG.Start(); prcExecuteFFMPEG.WaitForExit(); string strOutput = prcExecuteFFMPEG.StandardOutput.ReadToEnd(); } 我在顶部使用 System.Diagnositic 。 我通过命令提示发送以下命令。 (我在运行程序时从文本可视化工具中得到了这个结果 / kC:\Program Files\ffmpeg\bin\ffmpeg.exe - b:10000k -r25 -an -i concat:C:\视频转换\原始\Cam06 [21_48_59-22_29_19] .avi | C:\视频转换\原创\Cam06 [22_29_19-23_36_00]。 aviC:\视频转换\ test.avi 任何想法,为什么它不起作用。 我将参数更改为 / c dir *。* 然后我得到了输出,它按预期工作但我的高级代码无效。 谢谢解决方案 Here is the code I am using:private string ConvertVideoFiles(string strCommandLineSwitches){ Process prcExecuteFFMPEG = new Process(); prcExecuteFFMPEG.StartInfo.FileName = @"c:\windows\system32\cmd.exe "; //prcExecuteFFMPEG.StartInfo.WorkingDirectory = @"C:\"; prcExecuteFFMPEG.StartInfo.Arguments = strCommandLineSwitches; prcExecuteFFMPEG.StartInfo.UseShellExecute = false; prcExecuteFFMPEG.StartInfo.RedirectStandardOutput = true; prcExecuteFFMPEG.Start(); prcExecuteFFMPEG.WaitForExit(); string strOutput = prcExecuteFFMPEG.StandardOutput.ReadToEnd();}I am using System.Diagnositic at the top.I send in the following command which I know works via the command prompts. (I got this from the text visualizer while running the program/k "C:\Program Files\ffmpeg\bin\ffmpeg.exe" -b:10000k -r25 -an -i concat:"C:\Video conversion\Original\Cam06[21_48_59-22_29_19].avi|C:\Video conversion\Original\Cam06[22_29_19-23_36_00].avi" "C:\Video conversion\test.avi"Any ideas why it is not working.I changed the arguments to /c dir *.* and I got the output back and it worked as expected but my upper code is not working.Thanks 解决方案 这篇关于运行外部程序(ffmpeg)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-30 17:37