System.Diagnostics.Process로 프로세스를 시작할 수 있습니다. 다음 코드로 시도하고 있지만 작동하지 않습니다. 나는 당신의 솔루션과 매우 비슷한 짓을했는지콘솔 응용 프로그램을 실행하고 출력을 캡처하여 리터럴에 표시하려면 어떻게합니까?
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
public partial class VideoTest : System.Web.UI.Page
{
List<string> outputLines = new List<string>();
bool exited = false;
protected void Page_Load(object sender, EventArgs e)
{
string AppPath = Request.PhysicalApplicationPath;
Process myProcess = new Process();
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.FileName = AppPath + "\\bin\\ffmpeg.exe";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
myProcess.Exited += new EventHandler(ExitHandler);
myProcess.Start();
while (!exited)
{
// This is bad bad bad bad....
}
litTest.Text = "";
foreach (string line in outputLines)
litTest.Text += line;
}
private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
outputLines.Add(outLine.Data);
}
// Handle Exited event and display process information.
private void ExitHandler(object sender, System.EventArgs e)
{
exited = true;
}
}
아마도 콘솔 응용 프로그램에서이 코드를 테스트해야할까요? –
ffmpeg.exe 출력을 캡처 할 수있는 곳에이 응용 프로그램이 실행되는 동안 내 응용 프로그램이 차단되고 출력이 표시되지 않으면 Exited 이벤트가 정상적으로 작동합니다. 최근 ffmpeg는 색깔이므로 표준 출력으로 가고 있는지 모르겠습니다. 또한 스레드에서 실행해야합니까? 제대로 작동한다면 최종 솔루션을 공유하십시오. 감사합니다. – Marie