protected void Button1_Click(object sender, EventArgs e)//从这开始点击BUTTON上传文件。
{
if (this.FileUpload1.HasFile)
{
string saveName=DateTime.Now.Ticks.ToString();
string FilePath = Server.MapPath(".");
string m_strExtension = GetExtension(this.FileUpload1.PostedFile.FileName).ToLower();
string FileName=saveName+"."+m_strExtension;
this.FileUpload1.SaveAs(FilePath+"/"+FileName);
if (m_strExtension == "flv")
{
System.IO.File.Copy(Server.MapPath(FileName), Server.MapPath("Source_Flv/"+saveName+".flv"));
return;
}
string a=VideoConvertFlv(Server.MapPath(FileName),Server.MapPath("Source_Flv/"+saveName+".flv"),"200x200");
Response.Write(a);
}
}
public string VideoConvertFlv(string FromNamePath,string ExportNamePath,string WidthAndHeight)
{
string ffmpeg=Server.MapPath("ffmpeg.exe");
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.Arguments = " -i " + FromNamePath + " -ab 56 -ar 22050 -b 500 -r 15 -s " + WidthAndHeight + " " + ExportNamePath;
try
{
System.Diagnostics.Process.Start(startInfo);
//return ExportName;
System.IO.File.Delete(FromNamePath);
} catch(Exception err)
{
System.IO.File.Delete(FromNamePath);
return err.Message;
}
return "OK"; }
public string GetExtension(string fileName)
{
int i = fileName.LastIndexOf(".")+1;
string Name = fileName.Substring(i);
return Name;
}
{
if (this.FileUpload1.HasFile)
{
string saveName=DateTime.Now.Ticks.ToString();
string FilePath = Server.MapPath(".");
string m_strExtension = GetExtension(this.FileUpload1.PostedFile.FileName).ToLower();
string FileName=saveName+"."+m_strExtension;
this.FileUpload1.SaveAs(FilePath+"/"+FileName);
if (m_strExtension == "flv")
{
System.IO.File.Copy(Server.MapPath(FileName), Server.MapPath("Source_Flv/"+saveName+".flv"));
return;
}
string a=VideoConvertFlv(Server.MapPath(FileName),Server.MapPath("Source_Flv/"+saveName+".flv"),"200x200");
Response.Write(a);
}
}
public string VideoConvertFlv(string FromNamePath,string ExportNamePath,string WidthAndHeight)
{
string ffmpeg=Server.MapPath("ffmpeg.exe");
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.Arguments = " -i " + FromNamePath + " -ab 56 -ar 22050 -b 500 -r 15 -s " + WidthAndHeight + " " + ExportNamePath;
try
{
System.Diagnostics.Process.Start(startInfo);
//return ExportName;
System.IO.File.Delete(FromNamePath);
} catch(Exception err)
{
System.IO.File.Delete(FromNamePath);
return err.Message;
}
return "OK"; }
public string GetExtension(string fileName)
{
int i = fileName.LastIndexOf(".")+1;
string Name = fileName.Substring(i);
return Name;
}
你又是copy又是delete我怀疑是权限不够!
放心权限是绝对的Administrator级别的
被捕捉了 !
{
System.Diagnostics.Process.Start(startInfo);
//return ExportName;
System.IO.File.Delete(FromNamePath);
} catch(Exception err)
{
//System.IO.File.Delete(FromNamePath);
return err.Message;
}
把System.IO.File.Delete(FromNamePath); 注释掉,看一下
string ffmpeg=Server.MapPath("ffmpeg.exe");
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.Arguments = " -i " + FromNamePath + " -ab 56 -ar 22050 -b 500 -r 15 -s " + WidthAndHeight + " " + ExportNamePath; 2.你是调用进程来执行转换操作,检查一下你设置的运行参数有没有错误。我是认为可能是你的ffmpeg.exe这个应用程序在调用时,程序的绝对路径可能有问题。这个应该是程序运行的机子上的ffmpeg.exe的绝对路径。
1 private static Process DBProecess = new Process();
2 DBProecess.StartInfo.FileName = @"d:\oracle\ora92\bin\exp.exe";
sPath = sPath.EndsWith("\\") ? sPath : sPath + "\\";
DBProecess.StartInfo.Arguments = @"user/pass@ora file=" + sPath + arg;
DBProecess.StartInfo.UseShellExecute = false;
DBProecess.StartInfo.RedirectStandardOutput = true;
DBProecess.Start();
string strRst = DBProecess.StandardOutput.ReadToEnd();
DBProecess.Close();
你可以看看用这样的方式来执行你的转换