Created
February 25, 2020 07:21
-
-
Save Microncode/898ab7569ec1b16b4ea43265016bc0dd to your computer and use it in GitHub Desktop.
Here is a snap example of using the CSScreenRecorder using C#:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In order to get your own UserName and RegKey please order a license. | |
using (ScreenRecorder = new CSScreenRecorder.ScreenRecorder("UserName", "RegKey")) | |
{ | |
//Set the area to record | |
ScreenRecorder.RecordScreenHeight = Int32.Parse(txtHeight.Text); | |
ScreenRecorder.RecordScreenWidth = Int32.Parse(txtWidth.Text); | |
ScreenRecorder.RecordScreenTop = Int32.Parse(txtTop.Text); | |
ScreenRecorder.RecordScreenLeft = Int32.Parse(txtLeft.Text); | |
//Track mouse move | |
ScreenRecorder.TrackMouse = chkTrackMouse.Checked; | |
//Set the rotate style | |
ScreenRecorder.Rotate = CSScreenRecorder.RotateStyle.RotateNoneFlipNone; | |
//Set the Watermark | |
ScreenRecorder.WatermarkFont = new Font(new Font("Arial", 32), System.Drawing.FontStyle.Underline); | |
ScreenRecorder.WatermarkText = txtWatermark.Text; | |
//Set the frames rate (less FPS will be more accurate the time and with less errors) | |
ScreenRecorder.FramesPerSeconds = 10; | |
ScreenRecorder.VideoEncoderQuality = trcVideoEncoderQuality.Value; | |
picPreview.SizeMode = PictureBoxSizeMode.StretchImage; | |
//Set the audio recorder | |
ScreenRecorder.RecordAudio = chkRecordAudio.Checked; | |
ScreenRecorder.MP3Encoder = chkMP3Encoder.Checked; | |
ScreenRecorder.AudioEncoderQuality = trcAudioEncoderQuality.Value; | |
ScreenRecorder.AudioDeviceIndex = cboSoundDevices.SelectedIndex; | |
//Set the video codec | |
ScreenRecorder.CodecIndex = cboCodecs.SelectedIndex; | |
//On start event | |
ScreenRecorder.OnStartRecord += (o) => | |
{ | |
txtLog.Text = txtLog.Text + DateTime.Now + ":Start record\r\n"; | |
}; | |
//On pause record | |
ScreenRecorder.OnPauseRecord += (o) => | |
{ | |
txtLog.Text = txtLog.Text + DateTime.Now + ":Pause record\r\n"; | |
}; | |
//On unpause record | |
ScreenRecorder.OnUnPauseRecord += (o) => | |
{ | |
txtLog.Text = txtLog.Text + DateTime.Now + ":Unpause record\r\n"; | |
}; | |
//On stop record | |
ScreenRecorder.OnStopRecord += (o) => | |
{ | |
txtLog.Text = txtLog.Text + DateTime.Now + ":Stop record\r\n"; | |
}; | |
//On preview (get the bmp image) | |
ScreenRecorder.OnPreview += (o, bmp) => | |
{ | |
//Preview | |
Bitmap pImage = new Bitmap(bmp); | |
picPreview.Image = pImage; | |
}; | |
ScreenRecorder.OnError += (o, ErrorMessage, ErrorNumber) => | |
{ | |
txtLog.Text = txtLog.Text + DateTime.Now + ":Error - " + ErrorMessage + " (" + ErrorNumber + ")\r\n"; | |
}; | |
//Start to record | |
ScreenRecorder.StartRecording(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment