Пример #1
0
        void converter_OnNewConvertingState(object sender, EventArgs e)
        {
            Converter       converter = (Converter)sender;
            ConvertingState cs        = converter.ConvertingState;

            try
            {
                Invoke((MethodInvoker) delegate { label2.Text =
                                                      "Dauer:   " + cs.TimeSpan.ToString() +
                                                      "\nGröße:   " + FormatKilobytes(cs.KiloBytes) +
                                                      "\nBitrate: " + cs.Bitrate; });
            }
            catch (Exception) {}
        }
Пример #2
0
        void ffmpegProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
        {
            Regex regex = new Regex(@"size\=[\s]*([0-9]+)kB time\=([0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{2}) bitrate\= (.*)kbits/s");

            if (e.Data != null)
            {
                if (regex.IsMatch(e.Data))
                {
                    Match    m       = regex.Match(e.Data);
                    long     kB      = Convert.ToInt64(m.Groups[1].Value);
                    string[] tsArr   = m.Groups[2].Value.Split(new char[] { ':', '.' });
                    TimeSpan ts      = new TimeSpan(0, Convert.ToInt32(tsArr[0]), Convert.ToInt32(tsArr[1]), Convert.ToInt32(tsArr[2]), Convert.ToInt32(tsArr[3]) * 10);
                    float    bitrate = Convert.ToSingle(m.Groups[3].Value, new CultureInfo("en"));
                    ConvertingState = new ConvertingState()
                    {
                        Bitrate = bitrate, KiloBytes = kB, TimeSpan = ts
                    };
                }
            }
        }