#region //运行mencoder的视频解码器转换
        public string MChangeFilePhy(string vFileName, string playFile, string imgFile)
        {
            string tool = Server.MapPath(PublicMethod.mencodertool);
            if ((!System.IO.File.Exists(tool)) || (!System.IO.File.Exists(vFileName)))
            {
                return "";
            }
            string flv_file = System.IO.Path.ChangeExtension(playFile, ".flv");            //截图的尺寸大小,配置在Web.Config中,如:<add key="CatchFlvImgSize" value="240x180" />
            string FlvImgSize = PublicMethod.sizeOfImg;
            System.Diagnostics.ProcessStartInfo FilestartInfo = new System.Diagnostics.ProcessStartInfo(tool);
            FilestartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            FilestartInfo.Arguments = " " + vFileName + " -o " + flv_file + " -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=1000:mbd=2:mv0:trell:v4mv:cbp:last_pred=1:dia=-1:cmp=0:vb_strategy=1 -vf scale=" + widthOfFile + ":" + heightOfFile + " -ofps 12 -srate 22050 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames";
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo = FilestartInfo;
            //开始执行  
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardInput = true;
            p.Start();
            int pCode = Convert.ToInt32(p.WaitForExit(99999999));  //*发生异常的地方,视频一旦超过4M*
            pCode = p.ExitCode;
            if (pCode == 0)
            {     //截图         
                CatchImg(vFileName, imgFile);
            }
            p.Close();
            p.Dispose();
            return "";
        }
        #endregion
超过4M的视频就不能转码,也不可以截到图,发生以下异常,
{“p.BasePriority”引发了“System.InvalidOperationException”类型的异常 int 
“p.ExitCode”引发了“System.InvalidOperationException”类型的异常 int 
“p.ExitTime”引发了“System.InvalidOperationException”类型的异常 System.DateTime }
但不报错;请问高手怎样改才可以; 因为视频一般都大于4M,所以恳请高手帮帮忙.

解决方案 »

  1.   

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance 下面的键值Disable Performance Counters 设置为  0 。
      

  2.   

    好像你用的memcoder版本有点老,下个新的试下(r32492-4.2.5)
    http://sourceforge.net/projects/mplayer-win32/files/MPlayer%20and%20MEncoder/revision%2032492/MPlayer-rtm-svn-32492.7z/download把最后一个参数
    -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames
    改成
    -lavfopts format=flv
      

  3.   

    我在本机的cmd里面运行过,是没有事的,多大的视频文件都可以转换,但到了asp.net代码实现的时候就不可以了,调试时就发生了以上的异常;还有的就是你给的链接下载不了,THX
      

  4.   

    查过注册表没有“Disable Performance Counters ”这个名称,还有什么方法呢?请高手赐教