日期:2014-05-17  浏览次数:21039 次

关于C#解码视频文件提取一帧图片的问题!求高效方案啊!~....谢谢..谢谢....走过路过千万别错过....据说标题长了才会有人注意....

public void GetThumb(string videoFileName)
        {
            string thumbImg = @"E:\ct_file\program\movie\images\" + this.GetFileName(videoFileName).Replace("''","'") + ".jpg"; // 图片保存路径
            if (File.Exists(thumbImg))
            {
                execCmd(string.Format(@"update tb_movie set file_img='{0}' where file_name='{1}' and file_folder='{2}'", thumbImg.Replace("'", "''"), this.GetFileName(videoFileName), this.GetFileFolder(videoFileName)));
                return;
            }
            Process ffmpeg = new Process();
            ffmpeg.StartInfo.Arguments = " -i \"" + videoFileName + "\" -s 240*215 -ss 10 -vframes 1 -f image2 -vcodec mjpeg \"" + thumbImg + "\""; // arguments !
            ffmpeg.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "ffmpeg.exe";
            ffmpeg.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            ffmpeg.Start(); // start ! 
            ffmpeg.WaitForExit();
            ffmpeg.Close();
            ffmpeg.Dispose();
        }

我们目前使用的是别人的一个开源项目ffmepg.exe来获取视频的缩略图....但是我有点嫌弃它的效率...不知道有没有大神有更好的办法来提取视频的一帧图片....

------解决方案--------------------
开另一个号来顶起!~
------解决方案--------------------
MARK 路过!
------解决方案--------------------
这里还提到几个其它的wrapper,你可以看一下
http://stackoverflow.com/questions/2163036/solid-ffmpeg-wrapper-for-c-net