コード例 #1
0
        void Btn_recordClick(object sender, EventArgs e)
        {
            if (!File.Exists(Ini_File.Read("Loc", "ffmpeg")))
            {
                MessageBox.Show(
                    "Could not find FFmpeg.exe, please change your settings to set the FFmpeg.exe location.",
                    "FFmpeg.exe",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );

                return;
            }

            if (!recording)
            {
                start_record(Convert.ToInt32(1000 / numeric_fps.Value));
                btn_record.Text = "Stop";
            }
            else
            {
                stop_record();
                MainFormResize(sender, e);
                btn_record.Text = "Record";
            }

            recording = !recording;
        }
コード例 #2
0
ファイル: Form_Settings.cs プロジェクト: chidres/WebMCam
 void Form_SettingsLoad(object sender, System.EventArgs e)
 {
     text_ffmpeg.Text          = Ini_File.Read("Loc", "ffmpeg");
     text_temp.Text            = Ini_File.Read("Loc", "temp");
     text_args.Text            = Ini_File.Read("Cmd", "args");
     combo_image_format.Text   = Ini_File.Read("Fmt", "image");
     combo_pixel_format.Text   = Ini_File.Read("Fmt", "pixel");
     chk_delete_frames.Checked = Ini_File.Read("Fmt", "delete") == "True";
 }
コード例 #3
0
ファイル: Form_Settings.cs プロジェクト: chidres/WebMCam
 void Btn_saveClick(object sender, System.EventArgs e)
 {
     Ini_File.Write("Loc", "ffmpeg", text_ffmpeg.Text);
     Ini_File.Write("Loc", "temp", text_temp.Text);
     Ini_File.Write("Cmd", "args", text_args.Text);
     Ini_File.Write("Fmt", "image", combo_image_format.Text);
     Ini_File.Write("Fmt", "pixel", combo_pixel_format.Text);
     Ini_File.Write("Fmt", "delete", Convert.ToString(chk_delete_frames.Checked));
     Close();
 }
コード例 #4
0
        void MainFormLoad(object sender, EventArgs e)
        {
            MainFormResize(sender, e);

            Ini_File.Exists("Loc", "ffmpeg", String.Format("\"{0}\\ffmpeg.exe\"", Environment.CurrentDirectory));
            Ini_File.Exists("Loc", "temp", Environment.CurrentDirectory + "\\temp\\");
            Ini_File.Exists("Cmd", "args", "-r %rfps% -i \"%temp%f_%d.%format%\" -r %fps% -vb %bitrate%");
            Ini_File.Exists("Fmt", "pixel", "32bppRgb");
            Ini_File.Exists("Fmt", "image", "png");
            Ini_File.Exists("Fmt", "delete", "True");
        }
コード例 #5
0
        ImageFormat image_format_format()
        {
            image_format = Ini_File.Exists("Fmt", "image", "png");

            switch (image_format)
            {
            case "jpg":
                return(ImageFormat.Jpeg);

            case "bmp":
                return(ImageFormat.Bmp);

            default:
                return(ImageFormat.Png);
            }
        }
コード例 #6
0
        PixelFormat pixel_format_format()
        {
            switch (Ini_File.Exists("Fmt", "pixel", "32bppRgb"))
            {
            case "16bppRgb555":
                return(PixelFormat.Format16bppRgb555);

            case "24bppRgb":
                return(PixelFormat.Format24bppRgb);

            case "48bppRgb":
                return(PixelFormat.Format48bppRgb);

            default:
                return(PixelFormat.Format32bppRgb);
            }
        }
コード例 #7
0
        void stop_record()
        {
            timer_elapsed.Stop();
            timer_frame.Stop();

            // Show dialog and only continue if OK.
            var save = new SaveFileDialog();

            save.Title  = "Select a location and name for your webm";
            save.Filter = "WebM (*.webm)|*.webm|All files (*.*)|*.*";

            if (save.ShowDialog() == DialogResult.OK)
            {
                Visible = false;

                new Form_Frames(temp_storage).ShowDialog();

                // Now time for the conversion
                var ffmpeg = new ProcessStartInfo();
                ffmpeg.WorkingDirectory = Environment.CurrentDirectory;
                ffmpeg.FileName         = Ini_File.Read("Loc", "ffmpeg");
                ffmpeg.Arguments        = Ini_File.Read("Cmd", "args")
                                          .Replace("%temp%", temp_storage)
                                          .Replace("%duration%", Convert.ToString(time_elapsed + 1))
                                          .Replace("%bitrate%", Convert.ToString((3 * 8192) / time_elapsed) + "k")
                                          .Replace("%format%", Ini_File.Read("Fmt", "image"))
                                          .Replace("%rfps%", Convert.ToString(frame_count / time_elapsed))
                                          .Replace("%fps%", Convert.ToString(numeric_fps.Value)) + " " + save.FileName;

                Debug.WriteLine(ffmpeg.FileName + " " + ffmpeg.Arguments);

                var process = new Process {
                    StartInfo = ffmpeg
                };
                process.Start();
                process.WaitForExit();

                Visible = true;
            }

            if (Ini_File.Read("Fmt", "delete") == "True")
            {
                Directory.Delete(temp_storage, true);
            }
        }
コード例 #8
0
        void start_record(int fps)
        {
            temp_storage = String.Format(@"{0}{1}\", Ini_File.Read("Loc", "temp"), DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond);

            // If our temp dir doesn't exist we need to create it
            if (!Directory.Exists(temp_storage))
            {
                Directory.CreateDirectory(temp_storage);
            }

            frame_count  = 0;
            time_elapsed = 1;

            timer_frame.Interval = fps;

            timer_elapsed.Start();
            timer_frame.Start();
        }