Esempio n. 1
0
        public void Start(StartCmdOptions StartOptions)
        {
            _settings.IncludeCursor      = StartOptions.Cursor;
            _settings.Clicks.Display     = StartOptions.Clicks;
            _settings.Keystrokes.Display = StartOptions.Keys;

            if (File.Exists(StartOptions.FileName))
            {
                if (!StartOptions.Overwrite)
                {
                    if (!ServiceProvider.MessageProvider
                        .ShowYesNo("Output File Already Exists, Do you want to overwrite?", ""))
                    {
                        return;
                    }
                }

                File.Delete(StartOptions.FileName);
            }

            HandleVideoSource(StartOptions);

            HandleVideoEncoder(StartOptions);

            HandleAudioSource(StartOptions);

            HandleWebcam(StartOptions);

            if (StartOptions.FrameRate is int frameRate)
            {
                _settings.Video.FrameRate = frameRate;
            }

            if (StartOptions.AudioQuality is int aq)
            {
                _settings.Audio.Quality = aq;
            }

            if (StartOptions.VideoQuality is int vq)
            {
                _settings.Video.Quality = vq;
            }

            if (StartOptions.Delay > 0)
            {
                Thread.Sleep(StartOptions.Delay);
            }

            if (!_recordingModel.StartRecording(StartOptions.FileName))
            {
                return;
            }

            Task.Factory.StartNew(() =>
            {
                Loop(StartOptions);

                _recordingModel.StopRecording().Wait();

                Application.Exit();
            });

            // MouseKeyHook requires a Window Handle to register
            Application.Run(new ApplicationContext());
        }
Esempio n. 2
0
        public void Start(StartCmdOptions StartOptions)
        {
            _settings.IncludeCursor      = StartOptions.Cursor;
            _settings.Clicks.Display     = StartOptions.Clicks;
            _settings.Keystrokes.Display = StartOptions.Keys;

            if (File.Exists(StartOptions.FileName))
            {
                if (!StartOptions.Overwrite)
                {
                    if (!_messageProvider
                        .ShowYesNo("Output File Already Exists, Do you want to overwrite?", ""))
                    {
                        return;
                    }
                }

                File.Delete(StartOptions.FileName);
            }

            var videoSourceKind = HandleVideoSource(StartOptions);

            if (videoSourceKind == null)
            {
                WriteLine("Video source not set or invalid");

                return;
            }

            HandleAudioSource(StartOptions, out var mic, out var speaker);

            HandleWebcam(StartOptions);

            if (StartOptions.FrameRate is int frameRate)
            {
                _settings.Video.FrameRate = frameRate;
            }

            if (StartOptions.AudioQuality is int aq)
            {
                _settings.Audio.Quality = aq;
            }

            if (StartOptions.VideoQuality is int vq)
            {
                _settings.Video.Quality = vq;
            }

            if (StartOptions.Replay is int replayDuration && replayDuration > 0)
            {
                _settings.Video.RecorderMode   = RecorderMode.Replay;
                _settings.Video.ReplayDuration = replayDuration;
            }

            var videoWriter = HandleVideoEncoder(StartOptions, out _);

            if (StartOptions.Delay > 0)
            {
                Thread.Sleep(StartOptions.Delay);
            }

            if (!_recordingModel.StartRecording(new RecordingModelParams
            {
                VideoSourceKind = videoSourceKind,
                VideoWriter = videoWriter,
                Microphone = mic,
                Speaker = speaker
            }, StartOptions.FileName))
            {
                return;
            }

            Task.Factory.StartNew(() =>
            {
                Loop(StartOptions);

                _recordingModel.StopRecording().Wait();

                Application.Exit();
            });

            // MouseKeyHook requires a Window Handle to register
            Application.Run(new ApplicationContext());
        }
Esempio n. 3
0
        public void Start(StartCmdOptions StartOptions)
        {
            _settings.IncludeCursor      = StartOptions.Cursor;
            _settings.Clicks.Display     = StartOptions.Clicks;
            _settings.Keystrokes.Display = StartOptions.Keys;

            if (File.Exists(StartOptions.FileName))
            {
                if (!StartOptions.Overwrite)
                {
                    if (!_messageProvider
                        .ShowYesNo("Output File Already Exists, Do you want to overwrite?", ""))
                    {
                        return;
                    }
                }

                File.Delete(StartOptions.FileName);
            }

            var videoSourceKind = HandleVideoSource(StartOptions);

            if (videoSourceKind == null)
            {
                WriteLine("Video source not set or invalid");

                return;
            }

            var videoWriter = HandleVideoEncoder(StartOptions, out var videoWriterKind);

            if (StartOptions.Roll is int rollDuration && rollDuration > 0)
            {
                var internalWriter = videoWriter;
                videoWriter = new FFmpegRollingWriterItem(rollDuration, M => internalWriter.GetVideoFileWriter(M));
            }

            var audioSources = HandleAudioSource(StartOptions);

            HandleWebcam(StartOptions);

            if (StartOptions.FrameRate is int frameRate)
            {
                _settings.Video.FrameRate = frameRate;
            }

            if (StartOptions.AudioQuality is int aq)
            {
                _settings.Audio.Quality = aq;
            }

            if (StartOptions.VideoQuality is int vq)
            {
                _settings.Video.Quality = vq;
            }

            if (StartOptions.Delay > 0)
            {
                Thread.Sleep(StartOptions.Delay);
            }

            if (!_recordingModel.StartRecording(new RecordingModelParams
            {
                VideoSourceKind = videoSourceKind,
                VideoWriter = videoWriter,
                AudioItems = audioSources.Select(M => M.ToIsActive(true))
            }, StartOptions.FileName))
            {
                return;
            }

            Task.Factory.StartNew(() =>
            {
                Loop(StartOptions);

                _recordingModel.StopRecording().Wait();

                Application.Exit();
            });

            // MouseKeyHook requires a Window Handle to register
            Application.Run(new ApplicationContext());
        }