关于ProcessStartInfo的ffmpeg c#asp.net帮助
我编写了使用ffmpeg在c#asp.net中转换文件的代码。 执行它时显示错误“文件名,目录名称或卷标语法不正确”但我的路径是正确的。 那么这个解决方案是什么?
ProcessStartInfo info = new ProcessStartInfo("e:\ffmpeg\bin\ffmpeg.exe", "-i cars1.flv -same_quant intermediate1.mpg"); process.Start();
我尝试了另一种方法,如下所示。 但这也行不通。
ProcessStartInfo info = new ProcessStartInfo("ffmpeg.exe", "-i cars1.flv -same_quant intermediate1.mpg");
请帮助我使用c#asp.net中的ffmpeg将一种video文件格式转换为另一种video文件格式的示例代码。 提前致谢。
路径中的反斜杠( \
)被视为启动转义序列 。 要防止这种情况,请使用双反斜杠( \\
),或在字符串前加上@
。
ProcessStartInfo info = new ProcessStartInfo("e:\\ffmpeg\\bin\\ffmpeg.exe", "-i cars1.flv -same_quant intermediate1.mpg");
要么:
ProcessStartInfo info = new ProcessStartInfo(@"e:\ffmpeg\bin\ffmpeg.exe", "-i cars1.flv -same_quant intermediate1.mpg");
有包装库可用
还请参考
http://www.codeproject.com/Articles/24995/FFMPEG-using-ASP-NET
https://stackoverflow.com/questions/tagged/asp.net+c%23+video
string apppath = Request.PhysicalApplicationPath; string outf = Server.MapPath("."); string fileargs = "-i" + " " + "\"C:/file.mp4 \"" + " " + "\"C:/files/test.flv \""; Process myProcess = new Process(); myProcess.StartInfo.FileName = Server.MapPath(".")+"//ffmpeg.exe"; myProcess.StartInfo.Arguments = fileargs; myProcess.StartInfo.UseShellExecute = false; myProcess.StartInfo.CreateNoWindow = false; myProcess.StartInfo.RedirectStandardOutput = false; myProcess.Start(); myProcess.WaitForExit(50 * 1000);
谢谢
迪普
您需要在路径中使用反斜杠,请参阅下面这是我使用ffmpeg.exe创建video的方法
string sConverterPath = @"C:\ffmpeg.exe"; string sConverterArguments = @" -i "; sConverterArguments += "\"" + sAVIFile + "\""; sConverterArguments += " -s " + iVideoWidth.ToString() + "x" + iVideoHeight.ToString() + " "; sConverterArguments += " -b " + iVideoBitRate.ToString() + "k -ab " + iAudioBitRate.ToString() + "k -ac 1 -ar 44100 -r 24 -absf remove_extra "; sConverterArguments += "\"" + sOutputFile + "\""; Process oProcess = new Process(); oProcess.StartInfo.UseShellExecute = true; oProcess.StartInfo.Arguments = sConverterArguments; oProcess.StartInfo.FileName = sConverterPath;