Advertisement
Normantas

FFmpegCommunicator.cs

Jun 5th, 2021
1,091
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Text;
  5.  
  6. namespace GrayScaleFilter
  7. {
  8.     static class FFmpegCommunicator
  9.     {
  10.         private static string systemDir = System.AppDomain.CurrentDomain.BaseDirectory;
  11.         public static string fileName { get; set; } = "ffmpeg.exe";
  12.         public static string ffmpegPath { get; set; } = $@"{systemDir}ffmpeg\{fileName}";
  13.         private static ProcessStartInfo startInfo;
  14.         private static bool hasStarted = false;
  15.         private static Process exeProcess;
  16.         public static void Start()
  17.         {
  18.             // Starts Communication with FFMPEG
  19.             startInfo = new ProcessStartInfo();
  20.             startInfo.CreateNoWindow = false;
  21.             startInfo.UseShellExecute = false;
  22.             startInfo.FileName = fileName;
  23.             startInfo.WindowStyle = ProcessWindowStyle.Maximized;
  24.             hasStarted = true;
  25.             exeProcess = new Process();
  26.         }
  27.         public static void End()
  28.         {
  29.             // Ends communicationwith FFmpeg
  30.             exeProcess.Dispose();
  31.             hasStarted = false;
  32.         }
  33.         public static void Execute(string command)
  34.         {
  35.             // Sends a command to FFMPEG
  36.             startInfo.Arguments = command;
  37.             exeProcess = Process.Start(startInfo);
  38.             exeProcess.WaitForExit();
  39.            
  40.         }
  41.     }
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement