vb.net - 与 PowerShell 相比,进程运行速度非常慢
问题描述
我正在使用一个名为ffprobe.exe
(FFmpeg 库的一部分)的小脚本从视频文件中读取元数据。
这是我的代码:
'Setup the process
Dim Proc As New Process()
With Proc.StartInfo
.FileName = "C:\ffmpeg.exe"
.UseShellExecute = False
.CreateNoWindow = True
.RedirectStandardOutput = True
.RedirectStandardError = True
.Arguments = "C:\testVideoFile.mp4"
End With
'Start the process and wait for it to exit
Proc.Start()
'Set the process to be high-priority
Proc.PriorityClass = ProcessPriorityClass.High
'Listen for process output
ProcessOutput = ""
AddHandler Proc.OutputDataReceived, AddressOf Proc_OutputDataReceived
AddHandler Proc.ErrorDataReceived, AddressOf Proc_OutputDataReceived
AddHandler Proc.Exited, AddressOf Proc_Exited
Proc.BeginOutputReadLine()
Proc.BeginErrorReadLine()
Proc.EnableRaisingEvents = True
'Wait for the process to exit
PSProc.WaitForExit()
这段代码工作得很好。问题是它的运行时间比在 PowerShell 中运行的时间要长。PowerShell 看似立即运行脚本,但在我的应用程序中,上面的代码需要 1 到 3 秒才能执行。
我知道这个问题被问了很多,但我真的找不到一个明确的答案来解释为什么需要这么长时间。
我做错了什么还是这就是它的方式?
解决方案
推荐阅读
- python - 将 fit 文件转换为 healpix 地图
- oracle - 如何让用户在 Oracle 实时服务器的 PlSql 中输入值?
- logging - 即使日志文件中有错误,Nagios check_logs.pl 也会给出 OK
- javascript - Javascript:单参数 Array.map() 的不同行为取决于我是否使用花括号(不是两种形式都允许吗?)
- android - 无法在片段中获得幻灯片效果
- macos - hidd 进程在控制台中生成错误消息
- amazon-web-services - 已解决___使用 AWS S3 到 Webhost 没有给出关键错误
- node.js - Node.js 中的阻塞事件循环仍然存在问题吗?
- python - 我正在尝试在 Pycharm 中使用 Selenium webdriver,您可以在您的项目中使用它还是仅在 Python 控制台中使用它?
- flutter - 如何以简单的方式在本地保存对象列表