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

C# 如何从文件夹中的视频捕获缩略图,c#,asp.net,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 S

我正在创建一个类似于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
    }
  }
}
使用系统;
使用系统数据;
使用系统配置;
使用System.Linq;
使用System.Web;
使用System.Web.Security;
使用System.Web.UI;
使用System.Web.UI.HTMLControl;
使用System.Web.UI.WebControl;
使用System.Web.UI.WebControl.WebParts;
使用System.Xml.Linq;
使用系统文本;
使用All4DotNet;
命名空间直播
{
公共班级1
{
公共静态无效抓取单_Thumb()
{
//声明MediaManagerPro类的对象
MediaManagerPro oMediaManagerPro=新的MediaManagerPro();
//获得根路径
字符串strRootPath=HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath);
//设置ffmpeg文件的目录路径信息
oMediaManagerPro.FFMPEG_Path=HttpContext.Current.Server.MapPath(“~\\FFMPEG\\FFMPEG.exe”);
//设置源文件信息
oMediaManagerPro.SourceFile_Path=strRootPath+“视频”;
oMediaManagerPro.SourceFile_Name=“HelloWorld.flv”;
//设置输出文件信息
oMediaManagerPro.OutputFile_Path=strRootPath+“图像”;
//单拇指-免费版本中提供的属性
oMediaManagerPro.Frame_Time=“5”;
oMediaManagerPro.Image_Format=“jpg”;
oMediaManagerPro.Image\u Name=“Image”+DateTime.Now.Ticks;
////单拇指-完整版本中提供的属性
//oMediaManagerPro.宽度=320;
//oMediaManagerPro.高度=240;
//抓取缩略图
MediaInfo oMediaInfo=oMediaManagerPro.Grab_Thumb();
#区域打印输出信息
StringBuilder strOutputInfo=新StringBuilder();
strOutputInfo.Append(“Image Created=“+oMediaInfo.File_Name+”
); HttpContext.Current.Response.Write(strOutputInfo); #端区 } } }

我从

中得到了这段代码,这似乎是一个选项,它一直都在工作,FFMPEG是我们可以信赖的解决方案。您还可以尝试FFMPEG的托管版本,即Win FFMPEG。这可能会有所帮助。

请解释较大的文件会发生什么情况,是否会出现异常?您是否收到任何类型的错误消息?您的输出是否有损坏?没有正常运行的代码,但对于大于3mb的文件,不会生成缩略图。。