/////////////////////////////////////////////////////////////////////////////// // Construction and Initializing methods // /////////////////////////////////////////////////////////////////////////////// #region CONSTRUCTION /// <summary> /// Initializes a new instance of the DSRecordWithDMO class. /// </summary> /// <param name="newImageHandler">An <see cref="ImageFromVectorGraphics"/> /// with the callback.</param> /// <param name="newVideoExportProperties">A <see cref="VideoExportProperties"/> with /// the video export properties.</param> /// <param name="newPreviewWindow">A <see cref="Control"/> with /// the preview panel.</param> public DSRecordWithDMO( ImageFromVectorGraphics newImageHandler, VideoExportProperties newVideoExportProperties, Control newPreviewWindow) { try { // set the image provider this.imageHandler = newImageHandler; // set the video properties this.videoExportProperties = newVideoExportProperties; if (this.videoExportProperties.OutputVideoProperties.VideoCompressor != string.Empty) { // Create the filter for the selected video compressor this.videoCompressor = DirectShowUtils.CreateFilter( FilterCategory.VideoCompressorCategory, this.videoExportProperties.OutputVideoProperties.VideoCompressor); } if (this.videoExportProperties.OutputVideoProperties.AudioCompressor != string.Empty) { // Create the filter for the selected video compressor this.audioCompressor = DirectShowUtils.CreateFilter( FilterCategory.AudioCompressorCategory, this.videoExportProperties.OutputVideoProperties.AudioCompressor); } // Set up preview window this.previewWindow = newPreviewWindow; // Set up the graph if (!this.SetupGraph()) { throw new OperationCanceledException("The DirectShow graph could not be created," + " try to use another video or audio compressor."); } } catch { this.Dispose(); throw; } }
/// <summary> /// This method renders the picture content into an avi file. /// </summary> private void RenderGazeVideo() { this.newSplash.Header = "Rendering gaze and mouse video"; this.newSplash.IsPreviewVisible = true; var imageHandler = new ImageFromVectorGraphics( this.videoExportProperties.OutputVideoProperties, this.videoExportProperties.GazeVideoProperties.StreamStartTime, this.videoExportProperties.GazeVideoProperties.StreamEndTime, this.videoFramePusher, this.replayPicture.RenderFrame); imageHandler.Progress += this.imageHandler_Progress; imageHandler.Finished += this.imageHandler_Finished; // Setup usercam video filename. this.directShowInterface = new DSRecord( imageHandler, this.videoExportProperties, this.newSplash.PreviewWindow); this.directShowInterface.Completed += this.directShowInterface_Completed; this.replayPicture.ResetPicture(); if (this.replayPicture.InitDrawingElements()) { // Update pictures properties this.replayPicture.ReplayPosition = this.currentTrialTime; this.replayPicture.BeginUpdate(); this.Cursor = Cursors.Default; this.directShowInterface.Start(); } }
/////////////////////////////////////////////////////////////////////////////// // Construction and Initializing methods // /////////////////////////////////////////////////////////////////////////////// #region CONSTRUCTION /// <summary> /// Initializes a new instance of the DSRecordWithDMO class. /// </summary> /// <param name="newImageHandler">An <see cref="ImageFromVectorGraphics"/> /// with the callback.</param> /// <param name="newVideoExportProperties">A <see cref="VideoExportProperties"/> with /// the video export properties.</param> /// <param name="newPreviewWindow">A <see cref="Control"/> with /// the preview panel.</param> public DSRecordWithDMO( ImageFromVectorGraphics newImageHandler, VideoExportProperties newVideoExportProperties, Control newPreviewWindow) { try { // set the image provider this.imageHandler = newImageHandler; // set the video properties this.videoExportProperties = newVideoExportProperties; if (this.videoExportProperties.OutputVideoProperties.VideoCompressor != string.Empty) { // Create the filter for the selected video compressor this.videoCompressor = DirectShowUtils.CreateFilter( FilterCategory.VideoCompressorCategory, this.videoExportProperties.OutputVideoProperties.VideoCompressor); } if (this.videoExportProperties.OutputVideoProperties.AudioCompressor != string.Empty) { // Create the filter for the selected video compressor this.audioCompressor = DirectShowUtils.CreateFilter( FilterCategory.AudioCompressorCategory, this.videoExportProperties.OutputVideoProperties.AudioCompressor); } // Set up preview window this.previewWindow = newPreviewWindow; // Set up the graph if (!this.SetupGraph()) { throw new OperationCanceledException("The DirectShow graph could not be created," + " try to use another video or audio compressor."); } } catch { this.Dispose(); throw; } }