Example #1
0
        public static string Execute(FFMPEGParameters parameters)
        {
            if (String.IsNullOrWhiteSpace(FFMPEGExecutableFilePath))
            {
                throw new ArgumentNullException("Path to FFMPEG executable cannot be null");
            }

            if (parameters == null)
            {
                throw new ArgumentNullException("FFMPEG parameters cannot be completely null");
            }

            using (Process ffmpegProcess = new Process())
            {
                ProcessStartInfo info = new ProcessStartInfo(FFMPEGExecutableFilePath)
                {
                    Arguments              = parameters.ToString(),
                    WorkingDirectory       = Path.GetDirectoryName(FFMPEGExecutableFilePath),
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true
                };

                ffmpegProcess.StartInfo = info;
                ffmpegProcess.Start();
                string processOutput = ffmpegProcess.StandardError.ReadToEnd();
                ffmpegProcess.WaitForExit();
                PreviousBuffers.Enqueue(processOutput);
                lock (PreviousBuffers)
                {
                    while (PreviousBuffers.Count > MaximumBuffers)
                    {
                        PreviousBuffers.Dequeue();
                    }
                }

                return(processOutput);
            }
        }
Example #2
0
        public static string Execute(FFMPEGParameters parameters)
        {
            if (String.IsNullOrWhiteSpace(FFMPEGExecutableFilePath))
            {
                throw new ArgumentNullException("Path to FFMPEG executable cannot be null");
            }

            if (parameters == null)
            {
                throw new ArgumentNullException("FFMPEG parameters cannot be completely null");
            }

            using (Process ffmpegProcess = new Process())
            {
                ProcessStartInfo info = new ProcessStartInfo(FFMPEGExecutableFilePath)
                {
                    Arguments = parameters.ToString(),
                    WorkingDirectory = Path.GetDirectoryName(FFMPEGExecutableFilePath),
                    UseShellExecute = false,
                    CreateNoWindow = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError = true
                };

                ffmpegProcess.StartInfo = info;
                ffmpegProcess.Start();
                string processOutput = ffmpegProcess.StandardError.ReadToEnd();
                ffmpegProcess.WaitForExit();
                PreviousBuffers.Enqueue(processOutput);
                lock (PreviousBuffers)
                {
                    while (PreviousBuffers.Count > MaximumBuffers)
                    {
                        PreviousBuffers.Dequeue();
                    }

                }

                return processOutput;
            }

        }