1

ASP.NET にアップロードするときにビデオのサムネイルをキャプチャする方法を知りたいですか?

4

1 に答える 1

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アプリケーションのパスに応じてパスを変更する必要があります。

于 2011-07-15T16:24:53.877 に答える