我想知道如何在ASP.NET上传视频时捕获视频缩略图?
答案 0 :(得分:3)
首先,您还需要将其转换为可在任何地方使用的MP4。为此你可以使用ffmpeg工具,
创建缩略图,
//Create Thumbs
string thumbpath, thumbname;
string thumbargs;
string thumbre;
thumbpath = AppDomain.CurrentDomain.BaseDirectory + "Video\\Thumb\\";
thumbname = thumbpath + withoutext + "%d" + ".jpg";
thumbargs = "-i " + inputfile + " -vframes 1 -ss 00:00:07 -s 150x150 " + thumbname;
Process thumbproc = new Process();
thumbproc = new Process();
thumbproc.StartInfo.FileName = spath + "\\ffmpeg\\ffmpeg.exe";
thumbproc.StartInfo.Arguments = thumbargs;
thumbproc.StartInfo.UseShellExecute = false;
thumbproc.StartInfo.CreateNoWindow = false;
thumbproc.StartInfo.RedirectStandardOutput = false;
try
{
thumbproc.Start();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
thumbproc.WaitForExit();
thumbproc.Close();
但是,有关代码的更多详细信息,请参阅此链接。
http://ramcrishna.blogspot.com/2008/09/playing-videos-like-youtube-and.html
您需要根据Web应用程序的路径更改路径。