【发布时间】:2018-03-19 12:21:32
【问题描述】:
所以我使用下面的代码通过运行 ffmpeg 转换指定的文件,并且我需要进度条在进度条中可见,所以我需要让它在我的文本框中显示 cmd 输出实时并从那里让它通过进度条显示,有什么帮助吗?
private void convertbutton_Click(object sender, RoutedEventArgs e)
{
string resdir = AppDomain.CurrentDomain.BaseDirectory + "\\res";
Extract("ADC", AppDomain.CurrentDomain.BaseDirectory + "\\res", "res", "ffmpeg.exe");
string ffdir = AppDomain.CurrentDomain.BaseDirectory + "\\res\\ffmpeg.exe";
string arg = @"-y -activation_bytes ";
string arg1 = @" -i ";
string arg2 = @" -ab 80k -vn ";
string abytes = bytebox.Text;
string arguments = arg + abytes + arg1 + openFileDialog1.FileName + arg2 + saveFileDialog1.FileName;
Process ffm = new Process();
ffm.StartInfo.FileName = ffdir;
ffm.StartInfo.Arguments = arguments;
ffm.StartInfo.CreateNoWindow = true;
ffm.StartInfo.RedirectStandardOutput = true;
ffm.StartInfo.RedirectStandardError = true;
ffm.StartInfo.UseShellExecute = false;
ffm.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();
ffm.Start();
ffm.WaitForExit();
ffm.Close();
Directory.Delete(resdir, true);
}
FFMPEG 输出通常如下所示:
size= 4824kB time=00:08:13.63 bitrate= 80.1kbits/s speed= 33x
【问题讨论】:
-
@Borian 可能是,但我认为这可能是关于如何正确重定向进程输出并获取实际数据。
-
异步执行并在启动时显示进度条。异步结束后隐藏进度条。
-
stackoverflow.com/questions/11441517/… 有关于从 ffmpeg 解析进度信息的信息
标签: c# ffmpeg output progress-bar