public static bool changeVideoType(string fileName, string playFile)
{
//获取视频转换工具的路径
string ffmpeg = System.Web.HttpContext.Current.Server.MapPath("../") + ffmpegtool;
//获取需要转换的视频路径
string Name = System.Web.HttpContext.Current.Server.MapPath("../") + upFile + "/" + fileName;
if ((!System.IO.File.Exists(ffmpeg)) || (!System.IO.File.Exists(Name)))
{
return false;
}
//获取视频转换后需要保存的路径
string flv_file = playFile;
//创建Process对象
System.Diagnostics.Process pss = new System.Diagnostics.Process();
//不显示窗口
pss.StartInfo.CreateNoWindow = true;
//设置启动程序的路径
pss.StartInfo.FileName = ffmpeg;
pss.StartInfo.WorkingDirectory = System.Web.HttpContext.Current.Server.MapPath("../")+"tool/";
//设置执行的参数
pss.StartInfo.Arguments = " -i " + Name + "-ab 128 -ar 22050 -qscale 6 -r 29.97 -s " + widthOfFile + "x" + heightOfFile + " " + flv_file;
pss.StartInfo.UseShellExecute = false;
pss.StartInfo.RedirectStandardError = true;
pss.StartInfo.RedirectStandardInput = true;
pss.StartInfo.RedirectStandardOutput = true;
try
{
//启动转换工具
pss.Start();
while (!pss.HasExited)
{
continue;
}
return true;
}
catch
{
return false;
}
}