所以我通过stackoverflow阅读了很多,我发现了很多问题,试图解决与我类似的问题,但没有一个解决方案对我有效。所以这就是我所拥有的:
我有一个WPF GUI应用程序,它通过以下代码启动ffmpeg:
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 = @"-progress progresslog.txt -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();
MessageBox.Show("Conversion Complete!");
File.Delete("progresslog.txt");
Directory.Delete(resdir, true);
}所以在这个应用程序上我也有其他的进程,这些进程在完成它们正在做的事情后将它们的输出显示到文本框中,所以由于ffmpeg在cmd输出中输出它的转换进度,所以我需要在文本框中实时显示它。
我非常确定ffmpeg输出到stderr的结果与ffprobe相同。
我非常感谢任何人的帮助,因为几天的谷歌搜索到目前为止对我没有任何帮助。提前谢谢。
发布于 2018-03-21 13:52:07
尝试在ffm.Start()周围添加这些行。这应该会将ffmpeg输出写入调试控制台。如果可以,您可以调整代码以将输出写入您的WPF GUI。
ffm.EnableRaisingEvents = true;
ffm.OutputDataReceived += (s, ea) => { Debug.WriteLine($"STD: {ea.Data}"); };
ffm.ErrorDataReceived += (s, ea) => { Debug.WriteLine($"ERR: {ea.Data}"); };
ffm.Start();
ffm.BeginOutputReadLine();
ffm.BeginErrorReadLine();另请参阅此SO post
https://stackoverflow.com/questions/49388618
复制相似问题