コード例 #1
0
        private async void btStart_Click(object sender, EventArgs e)
        {
            mmLog.Clear();

            VideoEdit1.Debug_Mode = cbDebugMode.Checked;

            VideoEdit1.Video_Resize = cbResize.Checked;

            if (VideoEdit1.Video_Resize)
            {
                VideoEdit1.Video_Resize_Width  = Convert.ToInt32(edWidth.Text);
                VideoEdit1.Video_Resize_Height = Convert.ToInt32(edHeight.Text);
            }

            VideoEdit1.Video_FrameRate = Convert.ToDouble(cbFrameRate.Text);

            // apply capture parameters
            if (FilterHelpers.Filter_Supported_EVR())
            {
                VideoEdit1.Video_Renderer.VideoRenderer = VideoRendererMode.EVR;
            }
            else if (FilterHelpers.Filter_Supported_VMR9())
            {
                VideoEdit1.Video_Renderer.VideoRenderer = VideoRendererMode.VMR9;
            }
            else
            {
                VideoEdit1.Video_Renderer.VideoRenderer = VideoRendererMode.VideoRenderer;
            }

            if (!rbConvert.Checked)
            {
                VideoEdit1.Mode = VideoEditMode.Preview;
            }
            else
            {
                VideoEdit1.Mode            = VideoEditMode.Convert;
                VideoEdit1.Output_Filename = edOutput.Text;

                switch (cbOutputFormat.SelectedIndex)
                {
                case 0:
                {
                    var aviOutput = new AVIOutput();
                    SetAVIOutput(ref aviOutput);
                    VideoEdit1.Output_Format = aviOutput;

                    break;
                }

                case 1:
                {
                    var mkvOutput = new MKVv1Output();
                    SetMKVOutput(ref mkvOutput);
                    VideoEdit1.Output_Format = mkvOutput;

                    break;
                }

                case 2:
                {
                    var wmvOutput = new WMVOutput();
                    SetWMVOutput(ref wmvOutput);
                    VideoEdit1.Output_Format = wmvOutput;

                    break;
                }

                case 3:
                {
                    var dvOutput = new DVOutput();
                    SetDVOutput(ref dvOutput);
                    VideoEdit1.Output_Format = dvOutput;

                    break;
                }

                case 4:
                {
                    var webmOutput = new WebMOutput();
                    SetWebMOutput(ref webmOutput);
                    VideoEdit1.Output_Format = webmOutput;

                    break;
                }

                case 5:
                {
                    var ffmpegOutput = new FFMPEGOutput();
                    SetFFMPEGOutput(ref ffmpegOutput);
                    VideoEdit1.Output_Format = ffmpegOutput;

                    break;
                }

                case 6:
                {
                    var ffmpegOutput = new FFMPEGEXEOutput();
                    SetFFMPEGEXEOutput(ref ffmpegOutput);
                    VideoEdit1.Output_Format = ffmpegOutput;

                    break;
                }

                case 7:
                {
                    var mp4Output = new MP4Output();
                    SetMP4Output(ref mp4Output);
                    VideoEdit1.Output_Format = mp4Output;

                    break;
                }

                case 8:
                {
                    var mp4Output = new MP4HWOutput();
                    SetMP4HWOutput(ref mp4Output);
                    VideoEdit1.Output_Format = mp4Output;

                    break;
                }

                case 9:
                {
                    var gifOutput = new AnimatedGIFOutput();
                    SetGIFOutput(ref gifOutput);

                    VideoEdit1.Output_Format = gifOutput;

                    break;
                }

                case 10:
                {
                    var encOutput = new MP4Output();
                    SetMP4Output(ref encOutput);
                    encOutput.Encryption        = true;
                    encOutput.Encryption_Format = EncryptionFormat.MP4_H264_SW_AAC;

                    VideoEdit1.Output_Format = encOutput;

                    break;
                }
                }
            }

            VideoEdit1.Video_Effects_Enabled = true;
            VideoEdit1.Video_Effects_Clear();
            lbLogos.Items.Clear();
            ConfigureVideoEffects();

            VideoEdit1.Input_Clear_List();

            if (rbImagesPredefined.Checked)
            {
                predefinedImagesUsed = true;

                await VideoEdit1.Input_AddVideoBlankAsync(
                    TimeSpan.FromMilliseconds(10000),
                    TimeSpan.FromMilliseconds(0),
                    1280,
                    720,
                    Color.Black);
            }
            else
            {
                predefinedImagesUsed = false;

                if (!Directory.Exists(edImagesFolder.Text))
                {
                    MessageBox.Show(this, "Folder with images doesn't exists!");
                    return;
                }

                loadedFiles = EnumerateImageFiles(edImagesFolder.Text);

                int width  = Convert.ToInt32(edWidth.Text);
                int height = Convert.ToInt32(edHeight.Text);

                loadedImageFilename = null;
                if (loadedImage != null)
                {
                    loadedImage.Dispose();
                    loadedImage = null;
                }

                await VideoEdit1.Input_AddVideoBlankAsync(
                    TimeSpan.FromSeconds(loadedFiles.Length * 2),
                    TimeSpan.FromMilliseconds(0),
                    width,
                    height,
                    Color.Black);
            }

            await VideoEdit1.StartAsync();
        }