gpt4 book ai didi

c# - 在 C# 中使用 FFMPEG

转载 作者:行者123 更新时间:2023-11-30 22:27:37 25 4
gpt4 key购买 nike

我正在尝试使用 C# 中的 FFMPEG 从视频文件中去除音频。我知道执行此类操作的代码是什么(据我所知),但我不是 100% 确定我需要将 ffmpe.exe 文件保存在我的项目中的什么位置以及如何访问它。 到目前为止,我的代码如下:

public void stripAudioTest(string videoFilename, ExportProgressWindow callback, string destinationAudioFile)
{
string FFMPEG_PATH = "*************"; //not sure what to put here??????



string strParam = " -i " + videoFileName + " -ab 160k -ar 44100 -f wav -vn " + destinationAudioFile;
process(FFMPEG_PATH, strParam);
callback.Increment(100);


}

public void process(string Path_FFMPEG, string strParam)
{
try
{
Process ffmpeg = new Process();

ffmpeg.StartInfo.UseShellExecute = false;
ffmpeg.StartInfo.RedirectStandardOutput = true;
ffmpeg.StartInfo.FileName = Path_FFMPEG;
ffmpeg.StartInfo.Arguments = strParam;

ffmpeg.Start();

ffmpeg.WaitForExit();

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}`

如果有人有任何想法,请告诉我。任何帮助!

最佳答案

您可以使用任何您想要的绝对或相对路径。

但我建议不要使用相对路径,以防“当前目录”发生变化。

在 WinForms 下,您可以使用 ExecutablePath 并将 exe 放在您自己的 Bin 文件夹中。

 // winforms
string FFMPEG_PATH = Path.Combine(
Path.GetDirectoryName( Application.ExecutablePath),
"ffmpeg.exe");

对于控制台应用程序,我找不到如此简单的方法来获取 Exe 路径。

关于c# - 在 C# 中使用 FFMPEG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11210421/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com