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

            ProcessHandler.ProcessOutput output = p.StartInBlockingMode();
            Assert.IsNotNull(output);
        }
Esempio n. 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");
            }
        }
Esempio n. 3
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");
            }
        }
Esempio n. 4
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)));
        }