基于C#利用ffmpeg提取视频帧

利用ffmepg提取视频帧实际上是利用C#调用ffmepg命令行进行处理对应的视频,然后输出出视频帧

GetPicFromVideo(@"视频文件路径", "705x576", "1");

static public string GetPicFromVideo(string VideoName, string WidthAndHeight, string CutTimeFrame)
        {
            string ffmpeg = @"E:ffmpeginffmpeg.exe";//ffmpeg执行文件的路径
            string PicName = VideoName + ".jpg";//视频图片的名字,绝对路径
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.Arguments = " -i " + VideoName                    //视频路径
                                + " -r 1"                               //提取图片的频率
                                + " -y -frames 1 -f image2 -ss " + CutTimeFrame   //设置开始获取帧的视频时间
                                + " -t 513 -s " + WidthAndHeight             //设置图片的分辨率
                                + @" 路径\%d.jpg";  //输出的图片文件名,路径前必须有空格

            try
            {
                System.Diagnostics.Process.Start(startInfo);
                Thread.Sleep(5000);//线程挂起,等待ffmpeg截图完毕
            }
            catch (Exception)
            {
                return "";
            }
       

       //返回视频图片完整路径 if (System.IO.File.Exists(PicName)) return PicName; return ""; }
原文地址:https://www.cnblogs.com/cdp1591652208/p/9005854.html