Esempio n. 1
0
        static void usage(Capturer capturer)
        {
            Console.WriteLine("Usage : CaptureScreenCSharp.exe <outfilename> [left] [top] [width] [height] [fps] [v-codec] [a-codec] [audioline]\n");
            Console.WriteLine("[left, top, width, height] is the rectangle to be captured");
            Console.WriteLine("[v-codec] is the index of the video codec in the list to use.");
            Console.WriteLine("[a-codec] is the index of the audio codec in the list to use.");
            Console.WriteLine("[audioline] is the index of the audio line in the list to capture from");
            Console.WriteLine("If either codec is unspecified, it defaults to 'Microsoft Video 1' and 'GSM 6.10'");
            Console.WriteLine("If audioline is unspecified, it uses the microphone");
            Console.WriteLine("To capture the currently playing output, select the stereo, mono or wave mix");

            Console.WriteLine("Installed Video Codecs (Note : Not all of them may work)");

            for (int i = 0; i < capturer.VideoCodecsCount; i++)
            {
                string name = capturer.GetVideoCodecName(i);
                Console.WriteLine(string.Format("    {0}. {1}", i, name));
            }

            Console.WriteLine("\nInstalled Audio Codecs (Note : Not all of them may work)");
            for (int i = 0; i < capturer.AudioCodecsCount; i++)
            {
                string name = capturer.GetAudioCodecName(i);
                Console.WriteLine(string.Format("    {0}. {1}", i, name));
            }

            Console.WriteLine("\nAudio input lines");
            for (int i = 0; i < capturer.CurrentAudioDeviceLineCount; i++)
            {
                string name = capturer.GetCurrentAudioDeviceLineName(i);
                Console.WriteLine(string.Format("    {0}. {1}", i, name));
            }
        }
Esempio n. 2
0
        public SettingsForm()
        {
            InitializeComponent();

            lblProductName.Text    = Application.ProductName;
            lblProductVersion.Text = "Version " + Application.ProductVersion;

            _tempCapturer = new Capturer();
            _tempCapturer.RegistrationName = "demo";
            _tempCapturer.RegistrationKey  = "demo";

            cmbFPS.Items.AddRange(new object[] { 5f, 7.5f, 10f, 12f, 14.985f, 15f, 19.98f, 20f, 23.976f, 24f, 25f, 29.97f, 30f, 50f, 59.94f, 60 });

            for (int i = 0; i < _tempCapturer.AudioDeviceCount; i++)
            {
                string line = _tempCapturer.GetAudioDeviceName(i);
                cmbAudioDevices.Items.Add(line);
            }

            for (int i = 0; i < cmbAudioDevices.Items.Count; i++)
            {
                if (cmbAudioDevices.Items[i].ToString() == Program.Cfg.AudioDevice)
                {
                    cmbAudioDevices.SelectedIndex = i;
                    break;
                }
            }

            if (cmbAudioDevices.SelectedIndex == -1)
            {
                cmbAudioDevices.SelectedItem = _tempCapturer.CurrentAudioDeviceName;
                Program.Cfg.AudioDevice      = _tempCapturer.CurrentAudioDeviceName;
            }

            for (int i = 0; i < _tempCapturer.AudioCodecsCount; i++)
            {
                string codec = _tempCapturer.GetAudioCodecName(i);
                cmbAviAudioCodecs.Items.Add(codec);
            }

            for (int i = 0; i < cmbAviAudioCodecs.Items.Count; i++)
            {
                if (cmbAviAudioCodecs.Items[i].ToString() == Program.Cfg.AviAudioCodec)
                {
                    cmbAviAudioCodecs.SelectedIndex = i;
                    break;
                }
            }

            if (cmbAviAudioCodecs.SelectedIndex == -1)
            {
                cmbAviAudioCodecs.SelectedItem = _tempCapturer.CurrentAudioCodecName;
                Program.Cfg.AviAudioCodec      = _tempCapturer.CurrentAudioCodecName;
            }

            if (_tempCapturer.WebCamCount > 0)
            {
                for (int i = 0; i < _tempCapturer.WebCamCount; i++)
                {
                    string camera = _tempCapturer.GetWebCamName(i);
                    cmbWebCameras.Items.Add(camera);
                }

                for (int i = 0; i < cmbWebCameras.Items.Count; i++)
                {
                    if (cmbWebCameras.Items[i].ToString() == Program.Cfg.WebCameraDevice)
                    {
                        cmbWebCameras.SelectedIndex = i;
                        break;
                    }
                }

                if (cmbWebCameras.SelectedIndex == -1 && cmbWebCameras.Items.Count > 0)
                {
                    cmbWebCameras.SelectedIndex = _tempCapturer.CurrentWebCam;
                    Program.Cfg.WebCameraDevice = _tempCapturer.CurrentWebCamName;
                }
            }
            else
            {
                cmbWebCameras.Enabled     = false;
                tbWebCameraHeight.Enabled = false;
                tbWebCameraWidth.Enabled  = false;
                tbWebCameraX.Enabled      = false;
                tbWebCameraY.Enabled      = false;
            }

            for (int i = 0; i < _tempCapturer.VideoCodecsCount; i++)
            {
                string codec = _tempCapturer.GetVideoCodecName(i);
                cmbAviVideoCodecs.Items.Add(codec);
            }

            for (int i = 0; i < cmbAviVideoCodecs.Items.Count; i++)
            {
                if (cmbAviVideoCodecs.Items[i].ToString() == Program.Cfg.AviVideoCodec)
                {
                    cmbAviVideoCodecs.SelectedIndex = i;
                    break;
                }
            }

            if (cmbAviVideoCodecs.SelectedIndex == -1)
            {
                cmbAviVideoCodecs.SelectedItem = _tempCapturer.CurrentVideoCodecName;
                Program.Cfg.AviVideoCodec      = _tempCapturer.CurrentVideoCodecName;
            }

            for (int i = 0; i < _tempCapturer.WMVAudioCodecsCount; i++)
            {
                string codec = _tempCapturer.GetWMVAudioCodecName(i);
                cmbWmvAudioCodecs.Items.Add(codec);
            }

            for (int i = 0; i < cmbWmvAudioCodecs.Items.Count; i++)
            {
                if (cmbWmvAudioCodecs.Items[i].ToString() == Program.Cfg.WmvAudioCodec)
                {
                    cmbWmvAudioCodecs.SelectedIndex = i;
                    break;
                }
            }

            if (cmbWmvAudioCodecs.SelectedIndex == -1)
            {
                cmbWmvAudioCodecs.SelectedItem = _tempCapturer.CurrentWMVAudioCodecName;
                Program.Cfg.WmvAudioCodec      = _tempCapturer.CurrentWMVAudioCodecName;
            }

            for (int i = 0; i < _tempCapturer.WMVVideoCodecsCount; i++)
            {
                string codec = _tempCapturer.GetWMVVideoCodecName(i);
                cmbWmvVideoCodecs.Items.Add(codec);
            }

            for (int i = 0; i < cmbWmvVideoCodecs.Items.Count; i++)
            {
                if (cmbWmvVideoCodecs.Items[i].ToString() == Program.Cfg.WmvVideoCodec)
                {
                    cmbWmvVideoCodecs.SelectedIndex = i;
                    break;
                }
            }

            if (cmbWmvVideoCodecs.SelectedIndex == -1)
            {
                cmbWmvVideoCodecs.SelectedItem = _tempCapturer.CurrentWMVVideoCodecName;
                Program.Cfg.WmvVideoCodec      = _tempCapturer.CurrentWMVVideoCodecName;
            }

            cbEnableAudio.Checked     = Program.Cfg.EnableAudio;
            cbResizeVideo.Checked     = Program.Cfg.ResizeOutputVideo;
            tbWidth.Text              = Program.Cfg.OutputWidth.ToString();
            tbHeight.Text             = Program.Cfg.OutputHeight.ToString();
            cbKeepAspectRatio.Checked = Program.Cfg.KeepAspectRatio;
            cmbFPS.Text   = Program.Cfg.FPS.ToString();
            cbLog.Checked = Program.Cfg.WriteLog;

            tbWebCameraX.Text      = Program.Cfg.WebCameraWindowX.ToString();
            tbWebCameraY.Text      = Program.Cfg.WebCameraWindowY.ToString();
            tbWebCameraWidth.Text  = Program.Cfg.WebCameraWindowWidth.ToString();
            tbWebCameraHeight.Text = Program.Cfg.WebCameraWindowHeight.ToString();

            cmbAudioLines.Enabled     = cbEnableAudio.Checked;
            tbWidth.Enabled           = cbResizeVideo.Checked;
            tbHeight.Enabled          = cbResizeVideo.Checked;
            cbKeepAspectRatio.Enabled = cbResizeVideo.Checked;

            tabControl2.SelectedIndex = Program.Cfg.SelectedVideoCodecTab;

            cbCaptureMouseCursor.Checked  = Program.Cfg.CaptureMouseCursor;
            cbShowMouseHotSpot.Checked    = Program.Cfg.ShowMouseHotSpot;
            tbMouseAnimationDuration.Text = Program.Cfg.MouseAnimationDuration.ToString(CultureInfo.InvariantCulture);
            tbHotSpotRadius.Text          = Program.Cfg.MouseSpotRadius.ToString(CultureInfo.InvariantCulture);
            ccMouseHotSpotColor.ForeColor = Program.Cfg.MouseHotSpotColor;
            cbAnimateMouseClicks.Checked  = Program.Cfg.AnimateMouseClicks;
            cbAnimateMouseButtons.Checked = Program.Cfg.AnimateMouseButtons;
            ccMouseCursorLeftClickAnimationColor.ForeColor  = Program.Cfg.MouseCursorLeftClickAnimationColor;
            ccMouseCursorRightClickAnimationColor.ForeColor = Program.Cfg.MouseCursorRightClickAnimationColor;

            cmbFrameType.Items.Add("None");
            cmbFrameType.Items.Add("Solid");
            cmbFrameType.Items.Add("Dashed");
            cmbFrameType.Items.Add("Dotted");
            cmbFrameType.SelectedIndex = (int)Program.Cfg.CaptureAreaBorderType;
            ccFrameColor.ForeColor     = Program.Cfg.CaptureAreaBorderColor;
            tbFrameWidth.Text          = Program.Cfg.CaptureAreaBorderWidth.ToString(CultureInfo.InvariantCulture);
        }
        public Form1()
        {
            InitializeComponent();

            // Create Capturer instance
            capturer = new Capturer();
            capturer.RegistrationName = "demo";             // put your registration name here
            capturer.RegistrationKey  = "demo";             // put your registration key here


            // Get list of available audio devices
            for (int i = 0; i < capturer.AudioDeviceCount; i++)
            {
                string line = capturer.GetAudioDeviceName(i);
                cmbAudioDevices.Items.Add(line);
            }

            // Select current audio device
            cmbAudioDevices.SelectedIndex = capturer.CurrentAudioDevice;

            // Get list of available AVI audio codecs
            for (int i = 0; i < capturer.AudioCodecsCount; i++)
            {
                string codec = capturer.GetAudioCodecName(i);
                cmbAviAudioCodecs.Items.Add(codec);
            }

            // Select current AVI audio codec
            cmbAviAudioCodecs.SelectedIndex = capturer.CurrentAudioCodec;


            // Get list of available web camera devices
            for (int i = 0; i < capturer.WebCamCount; i++)
            {
                string camera = capturer.GetWebCamName(i);
                cmbWebCameras.Items.Add(camera);
            }

            // Select current web camera
            if (cmbWebCameras.Items.Count != 0)
            {
                cmbWebCameras.SelectedIndex = capturer.CurrentWebCam;
            }
            else
            {
                cmbWebCameras.Items.Add("No devices");
                cmbWebCameras.SelectedIndex = 0;
                cmbWebCameras.Enabled       = false;
                cbShowWebCamOverlay.Enabled = false;
            }

            // Get list of available AVI video codecs
            for (int i = 0; i < capturer.VideoCodecsCount; i++)
            {
                string codec = capturer.GetVideoCodecName(i);
                cmbAviVideoCodecs.Items.Add(codec);
            }

            // Select current AVI video codec
            cmbAviVideoCodecs.SelectedIndex = capturer.CurrentVideoCodec;

            // Get list of available WMV audio codecs
            for (int i = 0; i < capturer.WMVAudioCodecsCount; i++)
            {
                string codec = capturer.GetWMVAudioCodecName(i);
                cmbWmvAudioCodecs.Items.Add(codec);
            }

            // Select current WMV audio codec
            cmbWmvAudioCodecs.SelectedIndex = capturer.CurrentWMVAudioCodec;

            // Get list of available WMV video codecs
            for (int i = 0; i < capturer.WMVVideoCodecsCount; i++)
            {
                string codec = capturer.GetWMVVideoCodecName(i);
                cmbWmvVideoCodecs.Items.Add(codec);
            }

            // Select current WMV video codec
            cmbWmvVideoCodecs.SelectedIndex = capturer.CurrentWMVVideoCodec;


            // Fill list of FPS values
            cmbFPS.Items.AddRange(new object[] { 5f, 7.5f, 10f, 12f, 14.985f, 15f, 19.98f, 20f, 23.976f, 24f, 25f, 29.97f, 30f, 50f, 59.94f, 60 });
            // Select current FPS
            cmbFPS.SelectedItem = 14.985f;

            cbCaptureLayeredWindows.Checked = capturer.CaptureTransparentControls;

            nudMouseHotSpot.Value = capturer.MouseSpotRadius;
        }