ProgressBar added to WPF
<ProgressBar x:Name="progressBar1" HorizontalAlignment="Left" Height="10" Margin="80,160,0,0" VerticalAlignment="Top" Width="400" Minimum="0" Maximum="100"/> This function normally recodes video. But does not use ProgressBar
public void StartConvert() { var waitFlag = true; var path_ffmpeg = @"ffmpeg-20161107-34aeb5d-win32-static\bin\ffmpeg.exe"; var i = @"..\..\"; var dir_data = new DirectoryInfo(i + @"_data\"); var fullpath_ffmpeg = dir_data + path_ffmpeg; string outfile = " -i \"" + filefullname1 + "\" -codec:v libvpx -crf 10 -b:v 1M -f webm " + filefullname2; System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); psi.FileName = filefullname1; psi.Arguments = outfile; psi.UseShellExecute = true; psi.CreateNoWindow = false; // System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi); Thread.Sleep(1000);// utput.webm // p.WaitForExit(); if (waitFlag) { p.WaitForExit(); // wait for exit of called application } } This is taken from the Internet. http://www.freesmartsoft.com/Blog/Review?id=4
private void button_Click(object sender, RoutedEventArgs e) { //StartConvert2(); StartConvert(); } Updated
double duration = 0; string outString = null; while (!m_streamReader.EndOfStream) { outString = m_streamReader.ReadLine(); if ((duration == 0) && outString.Contains("Duration: ")) { //progress.Report(10); int index = outString.IndexOf(","); TimeSpan span = TimeSpan.Parse(outString.Remove(index).Remove(0, 10).Trim(new char[] { Convert.ToChar(":") }).Trim()); duration = span.TotalSeconds; } // Progress if ((duration > 0) && outString.Contains("time=")) { //progress.Report(50); string startStr = " time="; string stopStr = " bitrate="; int startIndex = outString.IndexOf(startStr); if (startIndex > 0) { int stopIndex = outString.IndexOf(stopStr); string time = outString.Substring(startIndex + startStr.Length, stopIndex - startIndex - startStr.Length); //double progress = 100.0 * double.Parse(time, m_culture.NumberFormat) / progressBar1.Value; var progress2 = 100.0 * double.Parse(time, m_culture.NumberFormat) / duration; m_progress = (int)progress2; } } progress.Report(m_progress); // progress.Report(80); }