Ejemplo n.º 1
0
        public ScreenRecorder(ScreenRecordOutput outputType, ScreencastOptions options, Rectangle captureRectangle)
        {
            if (string.IsNullOrEmpty(options.OutputPath))
            {
                throw new Exception("Screen recorder cache path is empty.");
            }

            FPS              = outputType == ScreenRecordOutput.GIF ? options.GIFFPS : options.ScreenRecordFPS;
            DurationSeconds  = options.Duration;
            CaptureRectangle = captureRectangle;
            CachePath        = options.OutputPath;
            OutputType       = outputType;

            Options = options;

            switch (OutputType)
            {
            default:
            case ScreenRecordOutput.FFmpeg:
                ffmpegCli = new FFmpegHelper(Options);
                break;

            case ScreenRecordOutput.GIF:
                imgCache = new HardDiskCache(Options);
                break;
            }
        }
Ejemplo n.º 2
0
        private void RefreshSourcesAsync(bool selectDevices = false)
        {
            btnRefreshSources.Enabled = false;
            DirectShowDevices devices = null;

            TaskEx.Run(() =>
            {
                using (FFmpegHelper ffmpeg = new FFmpegHelper(Options))
                {
                    devices = ffmpeg.GetDirectShowDevices();
                }
            },
                       () =>
            {
                cboVideoSource.Items.Clear();
                cboVideoSource.Items.Add(FFmpegHelper.SourceNone);
                cboVideoSource.Items.Add(FFmpegHelper.SourceGDIGrab);
                cboAudioSource.Items.Clear();
                cboAudioSource.Items.Add(FFmpegHelper.SourceNone);

                if (devices != null)
                {
                    cboVideoSource.Items.AddRange(devices.VideoDevices.ToArray());
                    cboAudioSource.Items.AddRange(devices.AudioDevices.ToArray());
                }

                if (selectDevices && cboVideoSource.Items.Contains(FFmpegHelper.SourceVideoDevice))
                {
                    Options.FFmpeg.VideoSource = FFmpegHelper.SourceVideoDevice;
                }

                cboVideoSource.Text = Options.FFmpeg.VideoSource;

                if (selectDevices && cboAudioSource.Items.Contains(FFmpegHelper.SourceAudioDevice))
                {
                    Options.FFmpeg.AudioSource = FFmpegHelper.SourceAudioDevice;
                }

                cboAudioSource.Text = Options.FFmpeg.AudioSource;

                btnRefreshSources.Enabled = true;
            });
        }
Ejemplo n.º 3
0
        private void RefreshSourcesAsync(bool selectDevices = false)
        {
            btnRefreshSources.Enabled = false;
            DirectShowDevices devices = null;

            TaskEx.Run(() =>
            {
                using (FFmpegHelper ffmpeg = new FFmpegHelper(Options))
                {
                    devices = ffmpeg.GetDirectShowDevices();
                }
            },
            () =>
            {
                cboVideoSource.Items.Clear();
                cboVideoSource.Items.Add(FFmpegHelper.SourceNone);
                cboVideoSource.Items.Add(FFmpegHelper.SourceGDIGrab);
                cboAudioSource.Items.Clear();
                cboAudioSource.Items.Add(FFmpegHelper.SourceNone);

                if (devices != null)
                {
                    cboVideoSource.Items.AddRange(devices.VideoDevices.ToArray());
                    cboAudioSource.Items.AddRange(devices.AudioDevices.ToArray());
                }

                if (selectDevices && cboVideoSource.Items.Contains(FFmpegHelper.SourceVideoDevice))
                {
                    Options.FFmpeg.VideoSource = FFmpegHelper.SourceVideoDevice;
                }

                cboVideoSource.Text = Options.FFmpeg.VideoSource;

                if (selectDevices && cboAudioSource.Items.Contains(FFmpegHelper.SourceAudioDevice))
                {
                    Options.FFmpeg.AudioSource = FFmpegHelper.SourceAudioDevice;
                }

                cboAudioSource.Text = Options.FFmpeg.AudioSource;

                btnRefreshSources.Enabled = true;
            });
        }