我嘗試從 ffmpeg 進程獲取輸出,但無法獲取輸出。在另一個進程和命令中,它工作正常,但輸出在啟動時立即返回! using (var process = new Process()) { process.StartInfo = new ProcessStartInfo() { FileName = LinkHelper.IPFS_PATH, Arguments = cmd, UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true }; process.ErrorDataReceived += FfmpegErrorRecieved; process.Start(); using (StreamReader reader = process.StandardOutput) { string output = await reader.ReadToEndAsync(); Console.WriteLine(output); } process.WaitForExit(); }輸出句柄之前!
2 回答

慕姐4208626
TA貢獻1852條經驗 獲得超7個贊
ffmpeg
將其輸出寫入stderr
and not?stdout
。因此,您必須從標準錯誤而不是標準輸出中
讀取。
因此,請改用以下幾行:
using?(StreamReader?reader?=?process.StandardError) { ????string?output?=?await?reader.ReadToEndAsync(); ????Console.WriteLine(output); }
- 2 回答
- 0 關注
- 120 瀏覽
添加回答
舉報
0/150
提交
取消