我写的代码使用的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。 提前致谢。
The backslashes (\
) in your path are considered to start escape sequences. To prevent this, either use double backslashes (\\
), or prefix the string with @
.
ProcessStartInfo info = new ProcessStartInfo("e:\\ffmpeg\\bin\\ffmpeg.exe",
"-i cars1.flv -same_quant intermediate1.mpg");
Or:
ProcessStartInfo info = new ProcessStartInfo(@"e:\ffmpeg\bin\ffmpeg.exe",
"-i cars1.flv -same_quant intermediate1.mpg");
有可用的包装库
http://www.ffmpeg-csharp.com/
另请参阅
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视频
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;