下载了最新版本的最新版本的 FFMpeg.exe
在win下dos命令执行命令切图成功。但是用程序实现老失败没反应而且不报错帖代码
做过的大哥帮我看看。
 /// <summary>
        /// 从视频画面中截取一帧画面为图片
        /// </summary>
        /// <param name="VideoName">视频文件pic/guiyu.mov</param>
        /// <param name="WidthAndHeight">图片的尺寸如:240*180</param>
        /// <param name="CutTimeFrame">开始截取的时间如:"1"</param>
        /// <returns></returns>
        public string GetPicFromVideo(string VideoName,string WidthAndHeight,string CutTimeFrame)
        {            string ffmpeg = @"ffmpeg/ffmpeg.exe";
            ffmpeg = Server.MapPath(ffmpeg);
            string PicName =Server.MapPath(Guid.NewGuid().ToString().Replace("-","")+".jpg");
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 
           startInfo.Arguments = " -i " + Server.MapPath(VideoName) + " -y -f image2 -t 1 -s "+ WidthAndHeight + " " + PicName ;      
         //   startInfo.Arguments = "-i  /video/happy_feet.flv -y -f image2 -t 1 -s 300*200  /video/1.jpg";
            try 
            {
                System.Diagnostics.Process.Start(startInfo);
                return PicName;
            }
            catch(Exception err)
            {
                return err.Message;
            }        
        }还有我在dos运行做视频转换FFMpeg.exe要出错转换的不能正常播放。哪位仁兄有FFMpeg.exe的麻烦丢个给我 谢谢。

解决方案 »

  1.   

    public static string VideoConvertImg(string FromName, string WidthAndHeight, string ExportName)
        {        string ffmpeg = HttpContext.Current.Server.MapPath("~/FLV/ffmpeg.exe");
            string Command = ffmpeg + "   -i   " + FromName + "   -y   -f   image2   -t   0.060   -s   " + WidthAndHeight + "   " + ExportName;                     //获取静态图 
            //string   Command   =   "E:\\FFmpeg\\ffmpeg.exe   -i   E:\\ClibDemo\\VideoPath\\admin\\a.wmv   -y -f   image2   -t   0.001   -s   300*200   "   +   ExportName;           
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo.FileName = "cmd.exe ";
            p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/FLV/");
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.CreateNoWindow = false;
            //开始执行 
            p.Start();
            p.StandardInput.WriteLine(Command);
            p.StandardInput.WriteLine("Exit ");
            return ExportName;
        }strFile = HttpContext.Current.Server.MapPath("~/FLV/071229paidui.mpg"); ;
            VideoConvertFlv(strFile, "480*360", "zh.flv");
            VideoConvertImg(strFile, "480*360", "zh.jpg");