如何从文件夹中的视频捕获缩略图

时间:2012-10-03 06:20:29

标签: c# asp.net

我正在创建一个类似于youtube的网站,所以在将视频(将采用.flv格式)上传到项目中的文件夹后,必须从相应的视频中捕获缩略图..这里我正在设计我的页面使用asp.net& C#...

我从网上获得了一些代码,但它仅处理大小为2-3Mb的视频....

任何人都可以帮我处理大型文件的代码..

这是我的代码..

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
using All4DotNet;

namespace LiveStreaming
{
public class Class1
{
    public static void GrabSingle_Thumb()
    {
        //Declare object of class MediaManagerPro
        MediaManagerPro oMediaManagerPro = new MediaManagerPro();

        //Get the rooth path
        string strRootPath = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath);

        //set the directory path info for ffmpeg file
        oMediaManagerPro.FFMPEG_Path = HttpContext.Current.Server.MapPath("~\\ffmpeg\\ffmpeg.exe");

        //Set source file info
        oMediaManagerPro.SourceFile_Path = strRootPath + "Videos";
        oMediaManagerPro.SourceFile_Name = "HelloWorld.flv";

        //set output file info
        oMediaManagerPro.OutputFile_Path = strRootPath + "Images";

        //Single Thumb - Properties available in free version
        oMediaManagerPro.Frame_Time = "5";
        oMediaManagerPro.Image_Format = "jpg";
        oMediaManagerPro.Image_Name = "Image_" + DateTime.Now.Ticks;

        ////Single Thumb - Properties available in full version
        //oMediaManagerPro.Width = 320;
        //oMediaManagerPro.Height = 240;

        //grab thumbnails
        MediaInfo oMediaInfo = oMediaManagerPro.Grab_Thumb();

        #region Print Output Information
        StringBuilder strOutputInfo = new StringBuilder();
        strOutputInfo.Append("Image Created = " + oMediaInfo.File_Name + "<br />");
        HttpContext.Current.Response.Write(strOutputInfo);
        #endregion
    }
  }
}

我从http://www.helpprogrammers.com/csharpsample.aspx

获得了此代码

1 个答案:

答案 0 :(得分:0)

这似乎是一个选项,它一直有效,FFMPEG是我们可以依赖的解决方案。您也可以尝试使用codeplex上的FFMPEG托管版本,即Win-FFMPEG。这可能有所帮助。