以前写的,供大家参考,ffmpeg文件大家可到官网下载了,注意ffmpeg的参数,和之间的空格!
使用时也要注意,文件有读写权限和.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()); } } |
附上本站www.xkde.com使用的ffmpeg下载地址:请把下面三个文件放在一个目录就行了.大家看文件名,应该知道它是什么功能了吧.ffmpeg还有其它许多参数,大家可以去搜搜.我就不一一例举了
http://xkde.com/backsite/Download/ffmpeg/ffmpeg.exe(这是切图用的)
http://xkde.com/backsite/Download/ffmpeg/ffplay.exe(这是播放用的)
http://xkde.com/backsite/Download/ffmpeg/pthreadGC2.dll(这是里面的dll)