public Open ( string fileName, int width, int height ) : void | ||
fileName | string | |
width | int | |
height | int | |
Résultat | void |
// On new frame private void camera_NewFrame(object sender, System.EventArgs e) { this.mHasFrame = true; if (this.EditMode == true || this.CameraClass == null || (this.CameraClass.Capture == CAPTUREFLAG.NOCAPTURE)) { return; } mMutexCapture.WaitOne(); if ((this.mIntervalsToSave > 0) || (this.CameraClass.Capture == CAPTUREFLAG.ALWAYS)) { // lets save the frame if (mAVIWriter == null && MotionConfiguration.Instance.StorageIsValid) { // create file name Motion.Core.DateTimeEx date = new Motion.Core.DateTimeEx(); String fileName = String.Format("{0}.{1}.{2}.avi", this.CameraClass.ID, (int)RecordMark.INVALID, date.TimeStamp); try { // create AVI writer mAVIWriter = new AVIWriterEx(this.CameraClass.Codec); // open AVI file mAVIWriter.Open(MotionConfiguration.Instance.StorageAVI + @"\" + fileName, cameraWindow.Camera.Width, cameraWindow.Camera.Height); DateTime n = DateTime.Now; string s = "" + n.Hour + ":" + n.Minute + ":" + n.Second; this.toolStripStatusLabelCapture.Text = string.Format(Translator.Instance.T("录像开始 ({0})"), s); this.CameraClass.Capturing = true; this.OnCameraViewRecordStarted(new CameraViewCaptureEventArgs(this)); mCaptureElapse = date.TimeStamp; } catch (Exception) { if (mAVIWriter != null) { mAVIWriter.Dispose(); mAVIWriter = null; } this.toolStripStatusLabelCapture.Text = Translator.Instance.T("录像失败"); this.CameraClass.Capturing = false; this.mCaptureElapse = 0; mMutexCapture.ReleaseMutex(); return; } } Camera camera = cameraWindow.Camera; if (camera != null && mAVIWriter != null) { Bitmap b = camera.LastFrame; if (b != null) { try { if (this.ShowBanner) { Bitmap bmp = CameraBanner.Render(b, this.CameraClass.Name, true); mAVIWriter.AddFrame(bmp); } else { mAVIWriter.AddFrame(b); } } catch (Exception) { this.toolStripStatusLabelCapture.Text = Translator.Instance.T("录像失败"); //OnCameraViewLog(new CameraViewLogEventArgs(Motion.Core.LogLevel.LOG_ERROR, ex.Message, this)); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace.ToString(), this.Camera.Name); } } } } mMutexCapture.ReleaseMutex(); }
// On new frame private void camera_NewFrame(object sender, System.EventArgs e) { this.mHasFrame = true; if (this.EditMode == true || this.CameraClass == null || (this.CameraClass.Capture == CAPTUREFLAG.NOCAPTURE)) { return; } mMutexCapture.WaitOne(); if ((this.mIntervalsToSave > 0) || (this.CameraClass.Capture == CAPTUREFLAG.ALWAYS)) { // lets save the frame if (mAVIWriter == null && MotionConfiguration.Instance.StorageIsValid) { // create file name Motion.Core.DateTimeEx date = new Motion.Core.DateTimeEx(); String fileName = String.Format("{0}.{1}.{2}.avi", this.CameraClass.ID, (int)RecordMark.INVALID, date.TimeStamp); try { // create AVI writer mAVIWriter = new AVIWriterEx(this.CameraClass.Codec); // open AVI file mAVIWriter.Open(MotionConfiguration.Instance.StorageAVI + @"\" + fileName, cameraWindow.Camera.Width, cameraWindow.Camera.Height); DateTime n = DateTime.Now; string s = "" + n.Hour + ":" + n.Minute + ":" + n.Second; this.toolStripStatusLabelCapture.Text = string.Format(Translator.Instance.T("录像开始 ({0})"), s); this.CameraClass.Capturing = true; this.OnCameraViewRecordStarted(new CameraViewCaptureEventArgs(this)); mCaptureElapse = date.TimeStamp; } catch (Exception) { if (mAVIWriter != null) { mAVIWriter.Dispose(); mAVIWriter = null; } this.toolStripStatusLabelCapture.Text = Translator.Instance.T("录像失败"); this.CameraClass.Capturing = false; this.mCaptureElapse = 0; mMutexCapture.ReleaseMutex(); return; } } Camera camera = cameraWindow.Camera; if (camera != null && mAVIWriter != null) { Bitmap b = camera.LastFrame; if (b != null) { try { if (this.ShowBanner) { Bitmap bmp = CameraBanner.Render(b, this.CameraClass.Name, true); mAVIWriter.AddFrame(bmp); } else { mAVIWriter.AddFrame(b); } } catch (Exception) { this.toolStripStatusLabelCapture.Text = Translator.Instance.T("录像失败"); //OnCameraViewLog(new CameraViewLogEventArgs(Motion.Core.LogLevel.LOG_ERROR, ex.Message, this)); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace.ToString(), this.Camera.Name); } } } } mMutexCapture.ReleaseMutex(); }