コード例 #1
0
 public void Convert(bool redirect, string message)
 {
     try
     {
         using (Process process = new Process())
         {
             Console.WriteLine();
             DisplayWriter.DisplayMessage(message, ConsoleColor.Green);
             process.StartInfo.FileName        = Path;
             process.StartInfo.Arguments       = Args;
             process.StartInfo.UseShellExecute = false;
             process.StartInfo.CreateNoWindow  = redirect;
             //process.StartInfo.RedirectStandardInput = redirect;
             //process.StartInfo.RedirectStandardOutput = redirect;
             process.Start();
             process.WaitForExit();
             if (process.ExitCode > 0)
             {
                 DisplayWriter.DisplayMessage($"Error {process.ExitCode}", ConsoleColor.Red);
                 Directory.Delete(ToolsConfig.TempPath, true);
                 Environment.Exit(1);
             }
             else
             {
                 DisplayWriter.DisplayMessage("Done!", ConsoleColor.Green);
             }
         }
     }
     catch
     {
         // errors
         throw;
     }
 }
コード例 #2
0
        static void Main(string[] args)
        {
            var    inputPath = args[0];
            string outputContainer;

            if (args.Length == 2)
            {
                outputContainer = args[1].TrimStart('-');
            }
            else
            {
                outputContainer = "mp4";
            }
            ToolsConfig.TempPath = Path.Combine(Path.GetDirectoryName(inputPath), ".temp");

            var mediaFile = new MediaFile(inputPath);

            DisplayWriter.DisplayInfo(mediaFile);

            var muxer = new Muxer(mediaFile);

            muxer.MuxerType = outputContainer;
            muxer.Convert();
            DisplayWriter.DisplayMessage("Press any key to exit ...", ConsoleColor.Green);
            Console.ReadKey();
            Directory.Delete(ToolsConfig.TempPath, true);
            Environment.Exit(0);
        }