public void CaptureScreen() { Encoder = new WMEncoder(); outputPath= @strFolderPath+@"C:\MyData\Captures\MyCaptures.wmv"; IWMEncSourceGroup2 SrcGrp; IWMEncSourceGroupCollection SrcGrpColl; SrcGrpColl = Encoder.SourceGroupCollection; SrcGrp = (IWMEncSourceGroup2)SrcGrpColl.Add ("SG_1"); IWMEncVideoSource2 SrcVid; //IWMEncAudioSource SrcAud; IWMEncSource SrcAud; SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO); SrcAud = (IWMEncSource) SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO); SrcVid.SetInput("ScreenCapture1","ScreenCap",""); SrcAud.SetInput("Default_Audio_Device","Device", ""); IWMEncProfileCollection ProColl; IWMEncProfile Pro; int i; long lLength; ProColl = Encoder.ProfileCollection; lLength = ProColl.Count; for( i = 0 ; i < lLength - 1; i++) Console.WriteLine (ProColl.Item(i).Name); for (i = 0; i <= lLength - 1; i++) { Pro = ProColl.Item(i); if (Pro.Name == "Screen Video/Audio High (CBR)") { SrcGrp.set_Profile((IWMEncProfile) Pro); break; } } IWMEncDisplayInfo Descr; Descr = Encoder.DisplayInfo; Descr.Author = "Stein.Jin"; Descr.Copyright = "Copyright information"; Descr.Description = "Text description of encoded content"; Descr.Rating = "Rating information"; Descr.Title = "Title of encoded content"; IWMEncAttributes Attr; Attr = Encoder.Attributes; Attr.Add("URL", "www.google.com"); IWMEncFile File; File = Encoder.File; File.LocalFileName = outputPath; SrcVid.CroppingBottomMargin = 2; SrcVid.CroppingTopMargin = 2; SrcVid.CroppingLeftMargin = 2; SrcVid.CroppingRightMargin = 2; Encoder.PrepareToEncode(true); Encoder.Start(); }
public void StartEncoder() { try { m_encoder.Start(); if (m_bFirstTime == true) { if (m_bTimerEnabled == true) { m_timer.Enabled = true; m_encoder.OnStateChange += new _IWMEncoderEvents_OnStateChangeEventHandler(OnStateChanged); } } else { m_timer.Enabled = true; } } catch (Exception exp) { WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Video Recordong Module ===>Screen Capture.cs line==> 229", exp, "Error Starting Encoder: " + exp.Message.ToString(), true); //Trace.WriteLine(exp.ToString()+"---"+exp.Message+"---"+exp.Source+exp.StackTrace+"---"+exp.TargetSite+"---"+exp.InnerException); //WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Error starting encoder: " + exp.Message.ToString()); } }
private void Page_Load(object sender, System.EventArgs e) { WMEncoder encoder = new WMEncoder(); WMEncProfile2 profile = new WMEncProfile2(); profile.LoadFromFile(Server.MapPath("~/scmeda.prx")); IWMEncSourceGroupCollection srcGrpColl = encoder.SourceGroupCollection; IWMEncSourceGroup srcGrp = srcGrpColl.Add("SingleEncode"); srcGrp.set_Profile(profile); IWMEncAudioSource audio = (WMEncoderLib.IWMEncAudioSource)srcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO); audio.SetInput(Server.MapPath("~/cabeloEncolheu.wma"), "", ""); audio.PreProcessPass = 0; IWMEncFile2 file = (IWMEncFile2)encoder.File; file.LocalFileName = Server.MapPath("~/cabeloEncolheu.mp3"); encoder.PrepareToEncode(true); encoder.Start(); }
public void Start() { if (encoder != null) { IWMEncFile File; File = encoder.File; File.LocalFileName = _savetoPath; encoder.Start(); } }
private void EncodeFile(EncodingProfileEnum Profile, EncoderInfo Info) { try { m_CurrentInfo = Info; DateTime Now = DateTime.Now; lblStatus.Text = " Starting to encode " + m_CurrentProfile.ToString() + " Starting time = " + Now.ToLongTimeString(); m_EncodingDone = false; // Create a WMEncoder object. m_Encoder = new WMEncoder(); m_Encoder.OnStateChange += new _IWMEncoderEvents_OnStateChangeEventHandler( OnStateChange); // Retrieve the source group collection. IWMEncSourceGroupCollection SrcGrpColl = m_Encoder.SourceGroupCollection; // Add a source group to the collection. IWMEncSourceGroup SrcGrp = SrcGrpColl.Add("SG_1"); // Add a video and audio source to the source group. IWMEncSource SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO); SrcAud.SetInput(Info.FileNameAndPath, "", ""); // Specify a file object in which to save encoded content. SetOutputFileName(Info.FileNameNoExtension); SelectProfile(SrcGrp); // Fill in the description object members. IWMEncDisplayInfo Descr = m_Encoder.DisplayInfo; Descr.Author = Info.Author; Descr.Copyright = "Valley Bible Church @2005"; Descr.Description = Info.Description; Descr.Rating = "All Audiences"; Descr.Title = Info.MessageTitle; // Add an attribute to the collection. IWMEncAttributes Attr = m_Encoder.Attributes; Attr.Add("URL", "IP address"); // Start the encoding process. // Wait until the encoding process stops before exiting the application. m_Encoder.PrepareToEncode(true); m_Encoder.Start(); } catch (Exception e) { lblError.Text = e.ToString(); Debug.WriteLine(e.ToString()); m_CurrentInfo = null; } }
static void Main() { try { // Create a WMEncoder object. WMEncoder Encoder = new WMEncoder(); // Retrieve the source group collection. IWMEncSourceGroupCollection SrcGrpColl = Encoder.SourceGroupCollection; // Add a source group to the collection. IWMEncSourceGroup SrcGrp = SrcGrpColl.Add("SG_1"); // Add a video and audio source to the source group. IWMEncSource SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO); SrcAud.SetInput("C:\\Inputfile.mpg", "", ""); IWMEncVideoSource2 SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO); SrcVid.SetInput("C:\\Inputfile.mpg", "", ""); // Crop 2 pixels from each edge of the video image. SrcVid.CroppingBottomMargin = 2; SrcVid.CroppingTopMargin = 2; SrcVid.CroppingLeftMargin = 2; SrcVid.CroppingRightMargin = 2; // Specify a file object in which to save encoded content. IWMEncFile File = Encoder.File; File.LocalFileName = "C:\\OutputFile.wmv"; // Choose a profile from the collection. IWMEncProfileCollection ProColl = Encoder.ProfileCollection; IWMEncProfile Pro; for (int i = 0; i < ProColl.Count; i++) { Pro = ProColl.Item(i); if (Pro.Name == "Windows Media Video 8 for Local Area Network (384 Kbps)") { SrcGrp.set_Profile(Pro); break; } } // Fill in the description object members. IWMEncDisplayInfo Descr = Encoder.DisplayInfo; Descr.Author = "Author name"; Descr.Copyright = "Copyright information"; Descr.Description = "Text description of encoded content"; Descr.Rating = "Rating information"; Descr.Title = "Title of encoded content"; // Add an attribute to the collection. IWMEncAttributes Attr = Encoder.Attributes; Attr.Add("URL", "IP address"); // Start the encoding process. // Wait until the encoding process stops before exiting the application. Encoder.PrepareToEncode(true); Encoder.Start(); Console.WriteLine("Press Enter when the file has been encoded."); Console.ReadLine(); // Press Enter after the file has been encoded. } catch (Exception e) { // TODO: Handle exceptions. } }
private void button1_Click(object sender, EventArgs e) { try { Encoder = new WMEncoder(); IWMEncSourceGroup SrcGrp; IWMEncSourceGroupCollection SrcGrpColl; SrcGrpColl = Encoder.SourceGroupCollection; SrcGrp = SrcGrpColl.Add("SG_1"); IWMEncSource SrcVid = null; IWMEncSource SrcAud = null; SrcVid = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO); SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO); SrcAud.SetInput("Default_Audio_Device", "Device", ""); SrcVid.SetInput("ScreenCapture1", "ScreenCap", ""); IWMEncProfileCollection ProColl; IWMEncProfile Pro; int i; long lLength; ProColl = Encoder.ProfileCollection; lLength = ProColl.Count; for (i = 0; i < lLength - 1; i++) { Pro = ProColl.Item(i); Console.WriteLine("<><>>" + Pro.Name); if (Pro.Name == "屏幕视频/音频 - 高(CBR)") { SrcGrp.set_Profile(Pro); break; } } IWMEncDisplayInfo Descr; Descr = Encoder.DisplayInfo; Descr.Author = ""; Descr.Copyright = ""; Descr.Description = ""; Descr.Rating = ""; Descr.Title = ""; IWMEncAttributes Attr; Attr = Encoder.Attributes; IWMEncFile File; File = Encoder.File; //if (label1.Text != string.Empty) //{ // File.LocalFileName = @"C:\1.WMA"; //保存路径 //} //else //{ // MessageBox.Show("请先选择路径!"); // return; //} File.LocalFileName = @"C:\1.WMA"; //保存路径 Encoder.Start(); } catch (Exception ex) { Encoder.Stop(); } }
void _backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { string glbstrErrLocation; WMEncoder Encoder = null; WMEncProfile2 Profile = null; IWMDRMContentAuthor DRMAuthor = null; IWMDRMProfileCollection DRMProColl = null; IWMDRMProfile DRMPro = null; IWMEncSourceGroup SrcGrp = null; IWMEncAudioSource SrcAud = null; IWMEncVideoSource2 SrcVid = null; _TwoPassEncoding = false; bool glbboolEncodingContinue = true;; DateTime time = DateTime.Now; try { Encoder = new WMEncoder(); Encoder.OnStateChange += new _IWMEncoderEvents_OnStateChangeEventHandler(this.Encoder_OnStateChange); _SrcGrpColl = Encoder.SourceGroupCollection; try { DRMAuthor = Encoder.EncoderDRMContentAuthor; DRMProColl = DRMAuthor.DRMProfileCollection; DRMPro = null; object vKeyID = null; if (_encodeInfo.DRMProfile != "None") { int intDRMProCount = 0; for (intDRMProCount = 0; intDRMProCount <= DRMProColl.Count - 1; intDRMProCount++) { if (DRMProColl.Item(intDRMProCount).Name == _encodeInfo.DRMProfile) { DRMPro = DRMProColl.Item(intDRMProCount); break; } } DRMAuthor.SetSessionDRMProfile(DRMPro.ID, ref vKeyID); } else { DRMAuthor.SetSessionDRMProfile(System.DBNull.Value.ToString(), ref vKeyID); DRMAuthor = null; DRMProColl = null; DRMPro = null; vKeyID = null; } } catch (Exception ex) { glbstrErrLocation = "Specify DRM Profile - " + ex.Message.ToString(); throw new ApplicationException(glbstrErrLocation, ex); } Profile = new WMEncProfile2(); Int32 intProContentType = 0; int intProVBRModeAudio = 0; int intProVBRModeVideo = 0; try { Profile.LoadFromFile(_encodeInfo.Profile); intProContentType = Profile.ContentType; intProVBRModeAudio = (int)Profile.get_VBRMode(WMENC_SOURCE_TYPE.WMENC_AUDIO, 0); intProVBRModeVideo = (int)Profile.get_VBRMode(WMENC_SOURCE_TYPE.WMENC_VIDEO, 0); } catch (Exception ex) { glbstrErrLocation = "Load Profile - " + ex.Message.ToString(); throw new ApplicationException(glbstrErrLocation, ex); } try { SrcGrp = _SrcGrpColl.Add("BatchEncode"); } catch (Exception ex) { glbstrErrLocation = "Source Group - " + ex.Message.ToString(); throw new ApplicationException(glbstrErrLocation, ex); } string strDestExtension = System.IO.Path.GetExtension(_encodeInfo.Destination); try { if (intProContentType == 1) { SrcAud = (WMEncoderLib.IWMEncAudioSource)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO); SrcAud.SetInput(_encodeInfo.Source, "", ""); } else if (intProContentType == 16) { SrcVid = (WMEncoderLib.IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO); SrcVid.SetInput(_encodeInfo.Source, "", ""); } else if (intProContentType == 17) { SrcAud = (WMEncoderLib.IWMEncAudioSource)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO); SrcAud.SetInput(_encodeInfo.Source, "", ""); SrcVid = (WMEncoderLib.IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO); SrcVid.SetInput(_encodeInfo.Source, "", ""); } else { _backgroundWorker.ReportProgress(0, "BatchEncode does not support this type of profile"); } } catch (Exception ex) { glbstrErrLocation = "Video / Audio Source - " + ex.Message.ToString(); throw new ApplicationException(glbstrErrLocation, ex); } try { SrcGrp.set_Profile(Profile); } catch (Exception ex) { glbstrErrLocation = "Encoding Profile - " + ex.Message.ToString(); throw new ApplicationException(glbstrErrLocation, ex); } IWMEncDisplayInfo Descr = Encoder.DisplayInfo; try { if (_encodeInfo.Title != "") { Descr.Title = _encodeInfo.Title; } if (_encodeInfo.Description != "") { Descr.Description = _encodeInfo.Description; } if (_encodeInfo.Author != "") { Descr.Author = _encodeInfo.Author; } if (_encodeInfo.Copyright != "") { Descr.Copyright = _encodeInfo.Copyright; } } catch (Exception ex) { glbstrErrLocation = "Display Information - " + ex.Message.ToString(); throw new ApplicationException(glbstrErrLocation, ex); } try { if (intProContentType == 16 || intProContentType == 17) { if (_encodeInfo.Crop == true) { SrcVid.CroppingBottomMargin = (int)_encodeInfo.CropBottom; SrcVid.CroppingTopMargin = (int)_encodeInfo.CropTop; SrcVid.CroppingLeftMargin = (int)_encodeInfo.CropLeft; SrcVid.CroppingRightMargin = (int)_encodeInfo.CropRight; } } } catch (Exception ex) { glbstrErrLocation = "Cropping - " + ex.Message.ToString(); throw new ApplicationException(glbstrErrLocation, ex); } try { if (intProContentType == 16 || intProContentType == 17) { SrcVid.Optimization = _encodeInfo.Preproc; } } catch (Exception ex) { glbstrErrLocation = "Video Optimization - " + ex.Message.ToString(); throw new ApplicationException(glbstrErrLocation, ex); } try { if (intProContentType == 1) { if (_encodeInfo.TwoPass == false) { SrcAud.PreProcessPass = 0; _TwoPassEncoding = false; } else { SrcAud.PreProcessPass = 1; _TwoPassEncoding = true; glbPassNumber = 1; } } else if (intProContentType == 16) { if (_encodeInfo.TwoPass == false) { SrcVid.PreProcessPass = 0; _TwoPassEncoding = false; } else { SrcVid.PreProcessPass = 1; _TwoPassEncoding = true; glbPassNumber = 1; } } else if (intProContentType == 17) { if (_encodeInfo.TwoPass == false) { SrcAud.PreProcessPass = 0; SrcVid.PreProcessPass = 0; _TwoPassEncoding = false; } else { switch (intProVBRModeAudio) { case 1: SrcAud.PreProcessPass = 1; break; case 2: SrcAud.PreProcessPass = 1; break; case 3: SrcAud.PreProcessPass = 0; break; case 4: SrcAud.PreProcessPass = 1; break; } switch (intProVBRModeVideo) { case 1: SrcVid.PreProcessPass = 1; break; case 2: SrcVid.PreProcessPass = 1; break; case 3: SrcVid.PreProcessPass = 0; break; case 4: SrcVid.PreProcessPass = 1; break; } _TwoPassEncoding = true; glbPassNumber = 1; } } else { _backgroundWorker.ReportProgress(0, "BatchEncode does not support this type of profile"); } } catch (Exception ex) { glbstrErrLocation = "Passes - " + ex.Message.ToString(); throw new ApplicationException(glbstrErrLocation, ex); } IWMEncFile2 File = (IWMEncFile2)Encoder.File; try { File.LocalFileName = _encodeInfo.Destination; } catch (Exception ex) { glbstrErrLocation = "Output File - " + ex.Message.ToString(); throw new ApplicationException(glbstrErrLocation, ex); } int intDurationAudio = 0; int intDurationVideo = 0; int intDurationFinal; try { _backgroundWorker.ReportProgress(0, "Preparing to encode"); Encoder.PrepareToEncode(true); } catch (Exception ex) { glbstrErrLocation = "Encoder Prepare - " + ex.Message.ToString(); throw new ApplicationException(glbstrErrLocation, ex); } try { if (SrcAud != null) { intDurationAudio = System.Convert.ToInt32(SrcAud.Duration / 1000); } } catch (Exception) { } try { if (SrcVid != null) { intDurationVideo = System.Convert.ToInt32(SrcVid.Duration / 1000); } } catch (Exception) { } if (intDurationAudio == 0) { intDurationFinal = intDurationVideo; } else if (intDurationVideo == 0) { intDurationFinal = intDurationAudio; } else { if (intDurationVideo >= intDurationAudio) { intDurationFinal = intDurationVideo; } else { intDurationFinal = intDurationAudio; } } glbintSourceDuration = intDurationFinal; try { if (glbboolEncodingContinue == true) { Encoder.Start(); do { if (_backgroundWorker.CancellationPending) { Encoder.Stop(); e.Cancel = true; _ev.Set(); } sReportPercentComplete(Encoder); }while (!_ev.WaitOne(1000)); } } catch (Exception ex) { glbstrErrLocation = "Encoder Start - " + ex.Message.ToString(); throw new ApplicationException(glbstrErrLocation, ex); } if (e.Cancel) { return; } else { _backgroundWorker.ReportProgress(0, "Encoding Complete"); return; } } finally { if (_SrcGrpColl != null) { try { Encoder.Stop(); _SrcGrpColl.Remove(0); } catch { } Marshal.ReleaseComObject(_SrcGrpColl); _SrcGrpColl = null; } if (Profile != null) { Marshal.ReleaseComObject(Profile); Profile = null; } if (Encoder != null) { Encoder.OnStateChange -= new _IWMEncoderEvents_OnStateChangeEventHandler(this.Encoder_OnStateChange); Marshal.ReleaseComObject(Encoder); Encoder = null; } e.Result = DateTime.Now - time; } }
internal override void Resume() { encoder.Start(); }
private void btnStart_Click(object sender, EventArgs e) { // 实例化Windows Media Encoder编码器 enc = new WMEncoderClass(); IWMEncSourceGroupCollection SrcGrpColl; IWMEncSourceGroup2 SrcGrp; // 音频源 //IWMEncAudioSource SrcAud; // 视频源 IWMEncVideoSource2 SrcVid; //IWMEncProfile2 Pro = new WMEncProfile2Class(); try { SrcGrpColl = enc.SourceGroupCollection; SrcGrp = (IWMEncSourceGroup2)SrcGrpColl.Add("SG_1"); SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO); Screen currentScreen; if (hWndURWPGSim2D == 0) {// 获取当前窗口所在屏幕作为当前屏幕 currentScreen = Screen.FromHandle(this.Handle); } else {// 获取待屏幕录像的URWPGSim2D程序主窗口所在屏幕作为当前屏幕 currentScreen = Screen.FromHandle((IntPtr)hWndURWPGSim2D); hWndURWPGSim2D = 0; } // 以当前屏幕设备作为视频来源设备 SrcVid.SetInput(currentScreen.DeviceName, "ScreenCap", ""); //SrcVid.SetInput("ScreenCapture1", "ScreenCap", ""); // 设置音频来源 //if (ckbSound.Checked) //{ // SrcAud = (IWMEncAudioSource)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO); // SrcAud.SetInput("Default_Audio_Device", "DEVICE", ""); //} foreach (IWMEncProfile wp in enc.ProfileCollection) { // 循环检查当前编码器实例中包含的全部配置文件 if (wp.Name.Equals(cmbEncoder.SelectedItem.ToString())) { // 如果当前配置文件(Profile)名称与选中的移植 // 将当前Profile设为当前视频源的配置文件 SrcGrp.set_Profile(wp); break; } } // 为当前编码器实例设定输出文件名称 enc.File.LocalFileName = txtFileName.Text; // 从界面输入取得待录屏区域左上角坐标/宽度/高度(单位为像素) int x = Convert.ToInt32(txtX.Text); int y = Convert.ToInt32(txtY.Text); int w = Convert.ToInt32(txtWidth.Text); int h = Convert.ToInt32(txtHeight.Text); // 适应多显示器环境 取得当前系统所有显示器构成的虚拟屏幕区域 Rectangle screenRect = SystemInformation.VirtualScreen; #region //// 为当前视频源设定宽度为当前屏幕宽度 //SrcVid.Width = currentScreen.Bounds.Width; //// 为当前视频源设定高度为当前屏幕高度 //SrcVid.Height = currentScreen.Bounds.Height; //// 对当前视频源进行裁剪 裁剪后的视频宽度高度即为待录像区域宽度高度 //// 左边裁掉待录像区域左上角坐标X值的大小 //SrcVid.CroppingLeftMargin = x; //// 上边裁掉待录像区域左上角坐标Y值的大小 //SrcVid.CroppingTopMargin = y; //// 右边裁掉总宽度和左边裁剪尺寸、待录像区域宽度之差 //SrcVid.CroppingRightMargin = SrcVid.Width - SrcVid.CroppingLeftMargin - w; //// 下边裁掉总高度和上边裁剪尺寸、待录像区域高度之差 //SrcVid.CroppingBottomMargin = SrcVid.Height - SrcVid.CroppingTopMargin - h; #endregion #region //int wm = SystemInformation.VirtualScreen.Width; //int hm = SystemInformation.VirtualScreen.Height; //SrcVid.Width = w; //SrcVid.Height = h; //float rx = (float)wm / (float)SrcVid.Width; //float ry = (float)hm / (float)SrcVid.Height; //SrcVid.CroppingLeftMargin = (int)(x / rx); //SrcVid.CroppingTopMargin = (int)(y / ry); //SrcVid.CroppingRightMargin = (int)((wm - x - w) / rx); //SrcVid.CroppingBottomMargin = (int)((hm - y - h) / ry); #endregion #region // 为当前视频源设定宽度为整个虚拟屏幕宽度 SrcVid.Width = screenRect.Width; // 为当前视频源设定高度为整个虚拟屏幕高度 SrcVid.Height = screenRect.Height; // 对当前视频源进行裁剪 裁剪后的视频宽度高度即为待录像区域宽度高度 // 左边裁掉待录像区域左上角坐标X值与虚拟屏幕左上角坐标X值之差 SrcVid.CroppingLeftMargin = x - screenRect.Left; // 上边裁掉待录像区域左上角坐标Y值与虚拟屏幕左上角坐标Y值之差 SrcVid.CroppingTopMargin = y - screenRect.Top; // 右边裁掉总宽度和左边裁剪尺寸、待录像区域宽度之差 SrcVid.CroppingRightMargin = SrcVid.Width - SrcVid.CroppingLeftMargin - w; // 下边裁掉总高度和上边裁剪尺寸、待录像区域高度之差 SrcVid.CroppingBottomMargin = SrcVid.Height - SrcVid.CroppingTopMargin - h; #endregion #region //SrcVid.Width = w; //SrcVid.Height = h; //float rx = (float)screenRect.Width / (float)SrcVid.Width; //float ry = (float)screenRect.Height / (float)SrcVid.Height; //SrcVid.CroppingLeftMargin = (int)((x - screenRect.Left) / rx); //SrcVid.CroppingTopMargin = (int)((y - screenRect.Top) / ry); //SrcVid.CroppingRightMargin = (int)((screenRect.Width - (x - screenRect.Left) - w) / rx); //SrcVid.CroppingBottomMargin = (int)((screenRect.Height - (y - screenRect.Top) - h) / ry); #endregion // 最小化Screencast程序主窗口 this.WindowState = FormWindowState.Minimized; // 开始编码 enc.Start(); btnStop.Enabled = true; btnStart.Enabled = false; this.TopMost = false; } catch (Exception e1) { MessageBox.Show(e1.Message); } }