Esempio n. 1
0
        private void MP4BoxProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            if (e.Data != null && e.Data.Length > 0)
            {
                if (e.Data.StartsWith("ISO File Writing:") || e.Data.StartsWith("Importing"))
                {
                    Int32 NewProgress;
                    String TaskName;
                    if (e.Data.StartsWith("Importing"))
                    {
                        Regex R = new Regex(@"^Importing (.*):.*[^\d](\d+)/100");
                        Match M = R.Match(e.Data);
                        NewProgress = Convert.ToInt32(M.Groups[2].Value);
                        String NewTask = M.Groups[1].Value;
                        if (CurrentTaskName != NewTask)
                        {
                            CurrentTaskName = NewTask;
                            CurrentTask++;
                        }

                        TaskName = "Muxing";
                        String TaskDesc = String.Format("Stream {0}/{1}", CurrentTask, TotalTracks);

                        if (NewProgress != Progress && !_cancelling)
                        {
                            Progress = NewProgress;
                            // raise the progress changed event
                            ExternalProcessProgressChangedEventArgs eArgs = new ExternalProcessProgressChangedEventArgs(
                              Progress, CurrentTask, TotalTracks, TaskName, TaskDesc, null);
                            async.Post(delegate(object ea)
                            { OnTaskProgressChanged((ExternalProcessProgressChangedEventArgs)ea); },
                              eArgs);
                        }
                    }
                    else
                    {
                        Regex R = new Regex(@"(\d+)/100");
                        Match M = R.Match(e.Data);
                        NewProgress = Convert.ToInt32(M.Groups[1].Value);

                        if (NewProgress != Progress && !_cancelling)
                        {
                            Progress = NewProgress;
                            // raise the progress changed event
                            ExternalProcessProgressChangedEventArgs eArgs = new ExternalProcessProgressChangedEventArgs(
                              Progress, 1, 1, "Writing", null, null);
                            async.Post(delegate(object ea)
                            { OnTaskProgressChanged((ExternalProcessProgressChangedEventArgs)ea); },
                              eArgs);
                        }
                    }

                    //Console.Write(e.Data);
                    //Console.CursorLeft = 0;
                }
                else
                {
            //                    Console.WriteLine(e.Data);
                }
            }
        }
Esempio n. 2
0
        private void FaacProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            if (e.Data != null && e.Data.Length > 0)
            {
                Regex R = new Regex(@"\(\s*(\d+)%\)");
                Match M = R.Match(e.Data);
                if (M.Success)
                {
                    int NewProgress = Convert.ToInt32(M.Groups[1].Value);

                    if (NewProgress != Progress && !_cancelling)
                    {
                        Progress = NewProgress;
                        // raise the progress changed event
                        ExternalProcessProgressChangedEventArgs eArgs = new ExternalProcessProgressChangedEventArgs(
                          Progress, 1, 1, "Encoding", null, null);
                        async.Post(delegate(object ea)
                        { OnTaskProgressChanged((ExternalProcessProgressChangedEventArgs)ea); },
                          eArgs);
                    }
                    //Console.CursorLeft = 0;
                    //Console.Write(e.Data);
                }
                else
                {
                    //Console.WriteLine(e.Data);
                }
            }
        }
Esempio n. 3
0
 protected virtual void OnTaskProgressChanged(ExternalProcessProgressChangedEventArgs e)
 {
     if (TaskProgressChanged != null)
         TaskProgressChanged(this, e);
 }
Esempio n. 4
0
        private void BesweetProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            if (e.Data != null && e.Data.Length > 0)
            {//[00:00:00:000]
                //Regex R = new Regex(@"^\[\d\d:\d\d:\d\d:\d\d\d\]");
                Regex R = new Regex(@"^\[(\d\d:\d\d:\d\d:\d\d\d)\].*transcoding");
                Match M = R.Match(e.Data);
                if (M.Success)
                {
                    Int32 Sep = M.Groups[1].Value.LastIndexOf(':');
                    TimeSpan CurrentPosition = TimeSpan.Parse(M.Groups[1].Value.Remove(Sep, 1).Insert(Sep, "."));
                    Int32 NewProgress = Convert.ToInt32(Math.Round(CurrentPosition.TotalMilliseconds / Duration.TotalMilliseconds * 100));

                    if (NewProgress != Progress && !_cancelling)
                    {
                        Progress = NewProgress;
                        // raise the progress changed event
                        ExternalProcessProgressChangedEventArgs eArgs = new ExternalProcessProgressChangedEventArgs(
                          Progress, 1, 1, "Decoding", null, null);
                        async.Post(delegate(object ea)
                        { OnTaskProgressChanged((ExternalProcessProgressChangedEventArgs)ea); },
                          eArgs);
                    }
                    //Console.CursorLeft = 0;
                    //Console.Write(M.Groups[1].Value);

                }
                else
                {
                    //Console.WriteLine(e.Data);
                }
            }
        }
Esempio n. 5
0
        private void MkvExtractProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            if (e.Data != null && e.Data.Length > 0)
            {
                if (e.Data.StartsWith("Progress: "))
                {
                    Regex R = new Regex(@"(\d+)%");
                    Match M = R.Match(e.Data);
                    Int32 NewProgress = Convert.ToInt32(M.Groups[1].Value);

                    if (NewProgress != Progress && !_cancelling)
                    {
                        Progress = NewProgress;
                        // raise the progress changed event
                        ExternalProcessProgressChangedEventArgs eArgs = new ExternalProcessProgressChangedEventArgs(
                          Progress, 1, 1, "Extracting", null, null);
                        async.Post(delegate(object ea)
                        { OnTaskProgressChanged((ExternalProcessProgressChangedEventArgs)ea); },
                          eArgs);
                    }
                }
                else
                {
            //                    Console.WriteLine(e.Data);
                }
            }
        }
Esempio n. 6
0
 static void CurrentProcess_TaskProgressChanged(object sender, ExternalProcessProgressChangedEventArgs e)
 {
     if (LastProgressUpdate != null && (LastProgressUpdate.CurrentTask != e.CurrentTask ||
         LastProgressUpdate.CurrentTaskName != e.CurrentTaskName ||
         LastProgressUpdate.TotalTasks != e.TotalTasks))
     {
         Console.WriteLine();
     }
     if (e.CurrentTaskDesc == null)
     {
         Console.Write("[{0}] Progress: {1}%", e.CurrentTaskName,
             e.ProgressPercentage);
     }
     else
     {
         Console.Write("[{0}] {2}: {1}%", e.CurrentTaskName,
             e.ProgressPercentage, e.CurrentTaskDesc);
     }
     Console.CursorLeft = 0;
     LastProgressUpdate = e;
 }