如何将视频文件转换为.flv格式和视频的清晰缩略图 [英] how to convert video file into .flv format and cerate thumb image of the video
本文介绍了如何将视频文件转换为.flv格式和视频的清晰缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我正在使用但无法转换的代码
here is the code that i am use but unable to convert
ReturnVideo(this.FileUpload1.FileName.ToString());
private bool ReturnVideo(string fileName)
{
string html = string.Empty;
//rename if file already exists
int j = 0;
string AppPath;
string inputPath;
string outputPath;
string imgpath;
AppPath = Request.PhysicalApplicationPath;
//Get the application path
inputPath = AppPath + "Admin\\Uploads\\Videos\\OriginalVideo";
//Path of the original file
outputPath = AppPath + "Admin\\Uploads\\Videos\\ConvertVideo";
//Path of the converted file
imgpath = AppPath + "Admin\\Uploads\\Videos\\Thumbs";
//Path of the preview file
string filepath = Server.MapPath("~/Admin/Uploads/Videos/OriginalVideo/" + fileName);
while (File.Exists(filepath))
{
j = j + 1;
int dotPos = fileName.LastIndexOf(".");
string namewithoutext = fileName.Substring(0, dotPos);
string ext = fileName.Substring(dotPos + 1);
fileName = namewithoutext + j + "." + ext;
filepath = Server.MapPath("~/Admin/Uploads/Videos/OriginalVideo/" + fileName);
}
try
{
this.FileUpload1.SaveAs(filepath);
}
catch
{
return false;
}
string outPutFile;
outPutFile = "~/Admin/Uploads/Videos/OriginalVideo/" + fileName;
int i = this.FileUpload1.PostedFile.ContentLength;
System.IO.FileInfo a = new System.IO.FileInfo(Server.MapPath(outPutFile));
while (a.Exists == false)
{
}
long b = a.Length;
while (i != b)
{
}
string cmd = " -i \"" + inputPath + "\\" + fileName + "\" \"" + outputPath + "\\" + fileName.Remove(fileName.IndexOf(".")) + ".wmv" + "\"";
ConvertNow(cmd);
ViewState["fileName"] = fileName.Remove(fileName.IndexOf(".")) + ".wmv";
string imgargs = " -i \"" + outputPath + "\\" + fileName.Remove(fileName.IndexOf(".")) + ".wmv" + "\" -f image2 -ss 1 -vframes 1 -s 280x200 -an \"" + imgpath + "\\" + fileName.Remove(fileName.IndexOf(".")) + ".jpg" + "\"";
ConvertNow(imgargs);
return true;
}
private void ConvertNow(string cmd)
{
string exepath;
string AppPath = Request.PhysicalApplicationPath;
//Get the application path
exepath = AppPath + "Admin\\ffmpeg.exe";
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = exepath;
//Path of exe that will be executed, only for "filebuffer" it will be "wmvtool2.exe"
proc.StartInfo.Arguments = cmd;
//The command which will be executed
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.RedirectStandardOutput = false;
proc.Start();
while (proc.HasExited == false)
{
}
}
推荐答案
上传和转换视频文件到Flash Video(flv)并使用ASP.NET处理程序进行渐进式流传输 [ ^ ]
请参阅此
http://bickelsandhuconsulting.com /developer/asp-net/convert-video-to-flv-and-create-thumbnails-from-file-using-c/ [ http://forums.asp.net/t/1356425.aspx/1 [ ^ ]
Refer this
http://bickelsandhuconsulting.com/developer/asp-net/convert-video-to-flv-and-create-thumbnails-from-file-using-c/[^]
http://forums.asp.net/t/1356425.aspx/1[^]
检查此解决方案
http://an-it- solution.blogspot.com/2008/12/convert-viedo-to-flv-using-cnet-on-web.html [
check this solution
http://an-it-solution.blogspot.com/2008/12/convert-viedo-to-flv-using-cnet-on-web.html[^]
这篇关于如何将视频文件转换为.flv格式和视频的清晰缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文