此操作需要借助于 ffmpeg.exe 文件,使用时要注意,文件需要有读写权限和 .net 调用 ffmpeg 的权限。
以下是代码片段:
if (MoveFileName.Substring(MoveFileName.LastIndexOf(".")) == ".wmv" || MoveFileName.Substring(MoveFileName.LastIndexOf(".")) == ".3gp")
{
//程序截图
string ffmpeg = Server.MapPath("ffmpeg/ffmpeg.exe");
string move = Server.MapPath("upfile/" + RMoveFileName);
pic = Myfunction.MakeNum(5) + Myfunction.MakeFileName() + ".jpg";
Process p = new Process();
p.StartInfo.FileName = ffmpeg;
p.StartInfo.Arguments = "-i " + move + " -y -f image2 -t 0.001 -s 120*120 " + Server.MapPath("upfile/img/" + pic);
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
try
{
p.Start();
p.Dispose();
p.Close();
}
catch (Exception ee)
{
Response.Write(ee.ToString());
}
}