示例#1
0
        private int ExecProcess(IList<string> cmds, FFMpegCallbacks sc)
        {
            //ensure that the arguments are in the correct Locale format
            // TODO: Useless since SOX is called internally. Remove.
            for ( int i = 0; i < cmds.Count; i++)
            {
                cmds[i] = string.Format(System.Globalization.CultureInfo.GetCultureInfo("en-US"), "%s", cmds[i]);
            }

            ProcessBuilder pb = new ProcessBuilder(cmds);
            pb.Directory(fileBinDir);

            var cmdlog = new Java.Lang.StringBuilder();

            foreach (string cmd in cmds)
            {
                cmdlog.Append(cmd);
                cmdlog.Append(' ');
            }

            sc.ShellOut(cmdlog.ToString());

            pb.RedirectErrorStream(true);
            var process = pb.Start();

            StreamGobbler errorGobbler = new StreamGobbler(this, process.ErrorStream, "ERROR", sc);
            StreamGobbler outputGobbler = new StreamGobbler(this, process.InputStream, "OUTPUT", sc);

            errorGobbler.Run();
            outputGobbler.Run();

            int exitVal = process.WaitFor();

            while (outputGobbler.IsAlive || errorGobbler.IsAlive);

            sc.ProcessComplete(exitVal);

            return exitVal;
        }