private void Record(string path)
        {
            if (Settings.AudioBitrate == 96)
            {
                A_bitrate = AudioBitrate.bitrate_96kbps;
            }
            else if (Settings.AudioBitrate == 128)
            {
                A_bitrate = AudioBitrate.bitrate_128kbps;
            }
            else if (Settings.AudioBitrate == 160)
            {
                A_bitrate = AudioBitrate.bitrate_160kbps;
            }
            else
            {
                A_bitrate = AudioBitrate.bitrate_192kbps;
            }

            if (Settings.AudioChannels == "5.1")
            {
                A_Channels = AudioChannels.FivePointOne;
            }
            else if (Settings.AudioChannels == "Mono")
            {
                A_Channels = AudioChannels.Mono;
            }
            else
            {
                A_Channels = AudioChannels.Stereo;
            }

            UpdateLogFile("Creating recording options.");
            RecorderOptions options = new RecorderOptions
            {
                RecorderMode = RecorderMode.Video,
                //If throttling is disabled, out of memory exceptions may eventually crash the program,
                //depending on encoder settings and system specifications.
                IsThrottlingDisabled = false,
                //Hardware encoding is enabled by default.
                IsHardwareEncodingEnabled = Settings.HardwareEncoding,
                //Low latency mode provides faster encoding, but can reduce quality.
                IsLowLatencyEnabled = Settings.LowLatency,
                //Fast start writes the mp4 header at the beginning of the file, to facilitate streaming.
                IsMp4FastStartEnabled = false,
                AudioOptions          = new AudioOptions
                {
                    Bitrate        = A_bitrate,
                    Channels       = A_Channels,
                    IsAudioEnabled = Settings.EnableAudio
                },
                VideoOptions = new VideoOptions
                {
                    BitrateMode           = BitrateControlMode.UnconstrainedVBR,
                    Bitrate               = Settings.VideoBitrate * 1000000,
                    Framerate             = Settings.FrameRate,
                    IsMousePointerEnabled = Settings.RecordMouse,
                    IsFixedFramerate      = true,
                    EncoderProfile        = H264Profile.Main
                }
            };

            UpdateLogFile("Creating Recorder object.");
            Rec = Recorder.CreateRecorder(options);
            Rec.OnRecordingFailed += Rec_OnRecordingFailed;
            Rec.OnStatusChanged   += Rec_OnStatusChanged;
            UpdateLogFile("Recording started.");
            Rec.Record(path);
        }