Piping process output to new process

前端 未结 2 1884
闹比i
闹比i 2021-01-16 08:48

I am having issues piping the output from the rtmpdump process to ffmpeg and I believe the issue is my process is stealing the output of rtmpdump.

In my research I

2条回答
  •  广开言路
    2021-01-16 09:02

    Came up with a simple solution.

    Using the the CMD process as your starting process.

    var p = new Process();
    p.StartInfo.FileName = "cmd.exe";
    p.StartInfo.Arguments = "/C rtmpdump.exe -v -r rtmp://somehost.com/app-name -o - |       ffmpeg.exe -loglevel quiet -i - -c:v copy -c:a libvo_aacenc -b:a 128k \"test.mp4\"";
    test.Start();
    

    And using this bit of code right after starting the process to get the last created rtmpdump process.

    Process[] allDumps = Process.GetProcessesByName("rtmpdump"); // get all rtmp processes
    if (allDumps.Any())
    {
        Process newestProcess = allDumps.OrderByDescending(x => x.StartTime).First(); // get the last one created     
        // Add the newly captured process to your list of processes for use later.
    }
    

提交回复
热议问题