public void TestRunInBlocking()
        {
            ProcessHandler p = new ProcessHandler(@"C:\Windows\System32\tree.com", @"c:\temp");

            ProcessHandler.ProcessOutput output = p.StartInBlockingMode();
            Assert.IsNotNull(output);
        }
示例#2
0
        internal void CompressVideo(string sourceFileName, string destinationFileName)
        {
            KillFfmpegProcess();
            if (!File.Exists(sourceFileName))
            {
                throw new FileNotFoundException("File " + sourceFileName + " is not exist");
            }
            if (String.IsNullOrEmpty(destinationFileName))
            {
                throw new InvalidOperationException("Destination can't be empty");
            }
            File.Delete(destinationFileName);
            if (File.Exists(destinationFileName))
            {
                throw new InvalidProgramException("Failed to delete destination file.");
            }
            ProcessHandler compressProcess = new ProcessHandler(ffmpegPath + @"ffmpeg.exe", String.Format(COMPRESS_VIDEO, sourceFileName, destinationFileName));

            ProcessHandler.ProcessOutput processOutput = compressProcess.StartInBlockingMode();

            if (processOutput.ErrorCode != 0)
            {
                throw new InvalidProgramException("Failed to compress movie");
            }
        }
        public void TestRunInNonBlocking()
        {
            ProcessHandler p = new ProcessHandler(@"C:\Windows\System32\tree.com", @"c:\");

            p.StartInNonBlockingMode();
            Thread.Sleep(100);
            ProcessHandler.ProcessOutput output = p.WaitForProcessToEnd();
            Assert.IsNotNull(output);
        }
示例#4
0
        internal void TrimMovie(string sourceFileName, string destinationFileName, int timeToKeepInSeconds)
        {
            KillFfmpegProcess();
            TimeSpan movieLength = FetchVideoDetails(sourceFileName).Duration;

            File.Delete(destinationFileName);
            ProcessHandler trimProcess = new ProcessHandler(ffmpegPath + @"ffmpeg.exe", String.Format(TRIM_COMPRESSED_MOVIE, movieLength - TimeSpan.FromSeconds(timeToKeepInSeconds), sourceFileName, TimeSpan.FromSeconds(timeToKeepInSeconds), destinationFileName));

            ProcessHandler.ProcessOutput processOutput = trimProcess.StartInBlockingMode();
            if (processOutput.ErrorCode != 0)
            {
                throw new InvalidProgramException("Failed to trim movie");
            }
        }
示例#5
0
        internal void EndVideoCapture()
        {
            if (null == ffmpegProcess)
            {
                throw new InvalidOperationException("There is no video to end");
            }

            ffmpegProcess.SendToProcess("q");

            ProcessHandler.ProcessOutput output = ffmpegProcess.WaitForProcessToEnd();
            if (output.Stderror.Contains("Could not find video device with name"))
            {
                throw new InvalidProgramException("'on screen capture recorder to video free' is not installed on current machine. Please install from: http://sourceforge.net/projects/screencapturer/files/ ");
            }
        }
示例#6
0
        internal VideoDetails FetchVideoDetails(string fileName)
        {
            KillFfmpegProcess();
            if (!File.Exists(fileName))
            {
                throw new FileNotFoundException("File " + fileName + " is not exist");
            }
            ProcessHandler compressProcess = new ProcessHandler(ffmpegPath + @"ffprobe.exe", String.Format(GET_VIDEO_DETAILS, fileName));

            ProcessHandler.ProcessOutput processOutput = compressProcess.StartInBlockingMode();
            if (processOutput.ErrorCode != 0)
            {
                throw new InvalidProgramException("Failure while trying to fetch video details: " + processOutput.Stderror);
            }
            Regex           rgx     = new Regex(VIDEO_DETAILS_REGEX);
            MatchCollection matches = rgx.Matches(processOutput.Stderror);

            if (matches.Count == 0)
            {
                throw new InvalidProgramException("Failed to fetch duration");
            }
            return(new VideoDetails(TimeSpan.Parse(matches[0].Groups[1].Value)));
        }