string mp4URL = Server.MapPath("~/Upload/") + "33.mp4";
string OutURL = Server.MapPath("~/Upload/") + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".png";
ffmpeg(mp4URL, OutURL, 3);
/// <summary>
///视频获取缩略图
/// </summary>
/// <param name="mp4">视频路径</param>
/// <param name="jpg">输出图片路径</param>
/// <param name="frames">视频帧数</param>
public void ffmpeg(string mp4, string jpg, int frames)
{
try
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "/ffmpeg/" + "\\ffmpeg.exe";
process.StartInfo.Arguments = $@"-i {mp4} -ss {frames} -f image2 {jpg}";
process.Start();
process.WaitForExit();
process.Close();
}
catch(Exception ex)
{
string msg = ex.Message;
}
}