Interact with ffmpeg from a .NET program - Write Input

前端 未结 2 600
日久生厌
日久生厌 2021-01-16 05:35

In reference to this question, as you can see I managed to run and receive data from the program.

However I didn\'t manage to submit data to it, for instance, while

2条回答
  •  攒了一身酷
    2021-01-16 06:03

    I succeeded, I'm using global variables like with the process in my code:

    private void RunProcessAsync(string FfmpegPath, string Parameters)
    {
      //Create process info
      ProcessStartInfo oInfo = new ProcessStartInfo(FfmpegPath, Parameters);
      //Set process properties
      oInfo.UseShellExecute = false;
      oInfo.CreateNoWindow = true;
      oInfo.RedirectStandardOutput = false;
      oInfo.RedirectStandardError = true;
      oInfo.RedirectStandardInput = true;
    
      process.StartInfo = oInfo;
    
      process.EnableRaisingEvents = true;
      process.ErrorDataReceived += new DataReceivedEventHandler(proc_ErrorDataReceived);
      process.Exited += new EventHandler(proc_Exited);
    
      process.Start();
      // this.pid = proc.Id;          
      process.BeginErrorReadLine();
    }
    
    public void stopProcess()
    {
      process.StandardInput.WriteLine("q");
    }
    

提交回复
热议问题