使用带有c#的asp.net和ffmpeg.exe将所有视频文件转换为flv
下面是我的代码。从给定视频中拍摄图像和将任何类型的视频转换为flv格式都不起作用。转换后,flv和thumb图像文件不会保存在temp(存储图像)数据(存储转换flv)文件夹中。该文件夹为空。 我正在调试代码,但它没有给出任何类型的异常和错误 请调试我的代码。等待您的回复专家 在Default2.aspx页面中 有一个文件上传控制和保存按钮 Default2.aspx.cs页面使用带有c#的asp.net和ffmpeg.exe将所有视频文件转换为flv,c#,asp.net,C#,Asp.net,下面是我的代码。从给定视频中拍摄图像和将任何类型的视频转换为flv格式都不起作用。转换后,flv和thumb图像文件不会保存在temp(存储图像)数据(存储转换flv)文件夹中。该文件夹为空。 我正在调试代码,但它没有给出任何类型的异常和错误 请调试我的代码。等待您的回复专家 在Default2.aspx页面中 有一个文件上传控制和保存按钮 Default2.aspx.cs页面 }您不应该使用ASP.NET中的命令行-它有几个权限问题(例如,Windows服务没有“真正的桌面”),并带来潜在的安
}您不应该使用ASP.NET中的命令行-它有几个权限问题(例如,Windows服务没有“真正的桌面”),并带来潜在的安全风险…您好,那么如何将amy电影文件转换为flv文件并保存到文件夹中?您不应该使用ASP.NET中的命令行-它有几个权限问题(例如,Windows服务没有“真正的桌面”)并带来潜在的安全风险…您好,那么如何将amy电影文件转换为flv文件并保存到文件夹?
protected void Page_Load(object sender, EventArgs e)
{
string ffmpegPath = "";
string tempLocation = "";
string mediaOutPath = "";
string thumbOutPath = "";
string currentFile = "";
ffmpegPath = Server.MapPath("~/ffmpeg/ffmpeg.exe");
tempLocation = Server.MapPath("~/VideoGallery/temp/");
mediaOutPath = Server.MapPath("~/VideoGallery/data/");
thumbOutPath = Server.MapPath("~/VideoGallery/thumb/");
}
protected void Submit1_ServerClick(object sender, System.EventArgs e)
{
if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
{
currentFile = System.IO.Path.GetFileName(File1.PostedFile.FileName);
try
{
Convert(tempLocation + currentFile, mediaOutPath + currentFile, thumbOutPath +
currentFile);
File1.PostedFile.SaveAs(tempLocation + currentFile);
Response.Write("The file has been uploaded.");
}
catch (Exception ex)
{
Response.Write("Error: " + ex.Message);
}
}
else
{
Response.Write("Please select a file to upload.");
}
}
protected void Convert(string fileIn, string fileOut, string thumbOut)
{
try
{
//convert flv
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = ffmpegPath;
proc.StartInfo.Arguments = "-i " + fileIn +
" -ar 22050 -ab 32 -f flv -s 320×240 -aspect 4:3 -y " + fileOut.Split('.')[0] +
".flv";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
proc.WaitForExit();
//convert img
proc.StartInfo.Arguments = "-i " + fileIn +
" -an -ss 00:00:03 -s 120×90 -vframes 1 -f mjpeg " + thumbOut.Split('.')[0] +
".jpg";
proc.Start();
proc.WaitForExit();
proc.Close();
}
catch (Exception ex)
{
Response.Write("Error: " + ex.Message);
}
}