如何与流程输出交互?

时间:2017-09-19 20:42:40

标签: vb.net shell process ffmpeg output

好的,所以目前我有一个使用VB.net中的进程运行FFmpeg的程序。我在startinfo中发送进程参数以及文件位置等其他内容。当我运行代码时,它将控制台输出发送到调试控制台;这可能是因为我有.UseShellExecute = False和processInfo.RedirectStandardOutput = True

我的问题是:我如何制作能够解释输出的东西?此外,对于FFmpeg,该过程是连续的,因此过程总是在大部分时间运行,并且在调试控制台中不断添加更多输出行。

我正在使用的代码:

edge_groups = email_df.groupby(["#Sender", "Recipient"], as_index=False).count().rename(columns={"time":"weight"})
email = nx.from_pandas_dataframe(edge_groups, '#Sender', 'Recipient', edge_attr = 'weight')

我试了这个没有运气。

Dim process As New Process
        Dim processInfo As New ProcessStartInfo
        processInfo.FileName = tempPath
        processInfo.Arguments = ("-r 1/.1 -i " + link + " -c copy " + saveLocation + "\" + streamerName + ".ts")
        processInfo.UseShellExecute = False
        processInfo.WindowStyle = ProcessWindowStyle.Hidden
        processInfo.CreateNoWindow = True
        processInfo.RedirectStandardOutput = True
        process.StartInfo = processInfo
        process.Start()

编辑:我现在有了这段代码:

Dim output As String
        Using StreamReader As System.IO.StreamReader = process.StandardOutput
            output = StreamReader.ReadToEnd().ToString
        End Using

但是我没有收到任何输出到richtextboxes?

我觉得它与streamReader有关,所以我删除了它仍然无法正常工作?我没有任何更多的想法。

1 个答案:

答案 0 :(得分:0)

Ffmpeg将所有调试信息输出到StdErr而不是StdOut。使用RedirectStandardError为true并尝试从进程中读取StandardError。