视频怎么以某一帧为封面(如何获取视频封面)

NET EF MVC在开发后台和接口上传视频的时候,需要截取视频的第一帧图片做视频封面,下面笔者介绍一个完整方法,以供参考:

public class ffmpeg : IHttpHandler

{

public void ProcessRequest(HttpContext context)

{

context.Response.ContentType = "text/plain";

using (System.Diagnostics.Process process = new System.Diagnostics.Process())

{

process.StartInfo.FileName = @"F:\soft\net相关\ffmpeg\ffmpeg\ffmpeg.exe";

//string path = context.Server.MapPath("/Files/"); //文件夹路径

string path = @"F:\pic_test"; //文件夹路径

string[] paths = Directory.GetFiles(path); //获取文件夹下全部文件路径

Listfiles = new List();

foreach (string filepath in paths)

{

//FileInfo file = new FileInfo(filepath); //获取单个文件

string fileName = Path.GetFileName(filepath);//获取文件名.

string face_photosname =
   Path.GetFileNameWithoutExtension(filepath);//获取文件名不包含后缀

//Distribution.Common.NetLog.WriteTextLog("fileName", fileName);

string videourl = path "\\" fileName;

string imgurl = path "\\" face_photosname ".jpg";

string Arguments = @"-i " videourl " - ss 15 -f image2 " imgurl;

process.StartInfo.Arguments = Arguments;

process.StartInfo.Arguments = @"-i " filepath " -ss 15 -f image2 " path "\\" face_photosname ".jpg";

process.Start();

}

context.Response.Write("操作成功");

context.Response.End();

}

}

public bool IsReusable

{

get

{

return false;

}

}

}

(0)

相关推荐