TsRemux.TsRemux.CaptureMPlayer C# (CSharp) Method

CaptureMPlayer() private static method

private static CaptureMPlayer ( Object SendingProcess, DataReceivedEventArgs OutLine ) : void
SendingProcess Object
OutLine DataReceivedEventArgs
return void
        private static void CaptureMPlayer(Object SendingProcess, DataReceivedEventArgs OutLine)
        {
            lock (_Serializer)
            {
                if (_FormInstance != null)
                {
                    // Parse only valid strings.
                    if (!string.IsNullOrEmpty(OutLine.Data))
                    {
                        string sOutLine = OutLine.Data;

                        // Check if this line contains a video timestamp.
                        if (sOutLine.Contains("V:"))
                        {
                            // It has, cut it out, hopefully MPlayer doesn't modify it's
                            // output format in future releases.
                            Regex R = new Regex(@".*(V:\s*[\d\.]+).*", RegexOptions.IgnoreCase);
                            Match M = R.Match(sOutLine);
                            string sCut = "";
                            if (M.Success)
                            {
                                Group G = M.Groups[1];
                                sCut = G.Value.Substring(2).Trim();
                            }

                            // Convert.
                            try
                            {
                                if (0 != sCut.Length)
                                {
                                    double dValue = Convert.ToDouble(sCut);
                                    // If this is the first we found, store it as base time.
                                    if (_FormInstance._dMPlayerStartTime < 0)
                                    {
                                        _FormInstance._dMPlayerStartTime = dValue;
                                        _FormInstance._dCurrentTrimTime = 0;
                                    }
                                    else
                                        _FormInstance._dCurrentTrimTime =
                                            dValue -
                                            _FormInstance._dMPlayerStartTime;
                                }
                            }
                            catch (FormatException)
                            {
                                // Ignore unknown output.
                            }
                            catch (OverflowException)
                            {
                                // Ignore unknown output.
                            }
                        }
                        else
                            _FormInstance._LogAddons.Add(sOutLine);
                    }
                }
            }
        }
TsRemux