使用C#通过ffmpeg转换音频格式器的问题 [英] Problem converting audio formars via ffmpeg with C#
本文介绍了使用C#通过ffmpeg转换音频格式器的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,很好,
我想用ffmpeg.exe将aac格式转换成mp3格式。
我发现它很简单,没有问题。
但是当我想将输出保存到特定目录时,我陷入了陷阱。
Hello huy,
I want to convert aac format to mp3 using the ffmpeg.exe.
I found its easy and no problem.
But I was caught in a trap when I wanted to save the output to specific directory.
private const string FffmpegArguments = "-acodec mp3 -ac 2 -ab 160k";
foreach (InputFile inputFile in this.inputFiles)
{
string input = Path.Combine(inputFile.Location, inputFile.Name);
string output = Path.Combine(
inputFile.Location,
Path.GetFileNameWithoutExtension(inputFile.Name) + "." + OutputExt);
ProcessStartInfo startInfo = new ProcessStartInfo(
"ffmpeg.exe",
string.Format(@" -i ""{0}"" {1} ""{2}""", input, FffmpegArguments, output))
{
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
Process proc = new Process { StartInfo = startInfo };
proc.Start();
}
它可以节省输出但是它的损坏似乎是什么问题?
当我尝试打开输出mp3时,我得到了这个:
输出mp3文件
推荐答案
正如谢尔盖所说,我宁愿使用:
As Sergey stated, I would rather use:
UseShellExecute = true,
RedirectStandardInput = false,
RedirectStandardOutput = false,
RedirectStandardError = false,
和看到如果它成功了。
and see if it does the trick.
这篇关于使用C#通过ffmpeg转换音频格式器的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文