Пример #1
0
        public static async void PerformTrim(
            Window window,
            string inputPath,
            string outputPath,
            string start,
            string duration)

        {
            Process trimProcess;

            if (!FF_Trim(out trimProcess, inputPath, outputPath, start, duration))
            {
                Console.WriteLine("Error starting FF_Trim");
                return;
            }

            ProgressWindow progressWindow = new ProgressWindow("Trimming");

            progressWindow.Show();

            window.IsEnabled = false;

            await Task.Run(() =>
            {
                string line;
                int p          = 0;
                bool gotCancel = false;

                // Set up progress window cancel
                progressWindow.OnGetCancel += (s, ee) =>
                {
                    gotCancel = true;
                    trimProcess.Kill();
                };
                while ((line = trimProcess.StandardError.ReadLine()) != null)
                {
                    if (gotCancel)
                    {
                        break;
                    }

                    // TODO: Parse output and update percent
                    p++;
                    if (progressWindow.progress != null)
                    {
                        progressWindow.progress.Report(p);
                    }

                    Console.WriteLine("FFMPEG: " + line);
                }
            });

            // Complete
            window.IsEnabled = true;
            //this.Closing -= ProgressWindow_Closing;
            trimProcess.Close();
            Console.WriteLine("Task Complete.");
            progressWindow.Complete();
        }
Пример #2
0
        public static async void PerformCrop(
            Window window,
            string inputPath,
            string outputPath,
            uint x,
            uint y,
            uint width,
            uint height)
        {
            // Lock the window during the operation
            window.IsEnabled = false;

            // TODO: Create a progress window

            Process cropProcess;

            if (!FF_Crop(out cropProcess, inputPath, outputPath, x, y, width, height))
            {
                Console.WriteLine("Error starting FF_Crop");
                return;
            }

            ProgressWindow progressWindow = new ProgressWindow("Cropping");

            progressWindow.Show();

            // Parse process output and update progress bar

            window.IsEnabled = false;

            await Task.Run(() =>
            {
                string line;
                int p          = 0;
                bool gotCancel = false;

                // Set up progress window cancel
                progressWindow.OnGetCancel += (s, ee) =>
                {
                    gotCancel = true;
                    cropProcess.Kill();
                };
                while ((line = cropProcess.StandardError.ReadLine()) != null)
                {
                    if (gotCancel)
                    {
                        break;
                    }
                    // TODO: Parse output and update percent
                    p++;
                    if (progressWindow.progress != null)
                    {
                        progressWindow.progress.Report(p);
                    }

                    Console.WriteLine("FFMPEG: " + line);
                }
            });

            // Complete
            window.IsEnabled = true;
            //this.Closing -= ProgressWindow_Closing;
            cropProcess.Close();
            Console.WriteLine("Task Complete.");
            progressWindow.Complete();
        }