Kiosk process on startup in .NET (ffmpeg)

I try to run ffmpeg as a process in .NET (C #), but in some cases, depending on the arguments (in particular, if I omit the video arguments to create an audio file), it stops, It starts, displays some lines, but then just stops (using 0% CPU). When the parent .NET process is killed, it continues, and if I leave it, ffmpeg creates the file correctly. I thought this could be due to using Peek() to view the stream, so I just simplified it to the following, which behaves the same way:

 _process = new Process { StartInfo = { UseShellExecute = false, RedirectStandardOutput = false, RedirectStandardError = true, FileName = "c:\\ffmpeg.exe", Arguments = string.Format( "-i {0} {1} {2} {3} -y {4}", inputPath, videoArgs, audioArgs, options, outputPath) } }; _process.Start(); _process.WaitForExit(); 

ffmpeg comes to the point where it displays information about the input video / audio streams before stopping. Running a command using the command line works as expected.

Does anyone know what the problem is?

Edit:

Just add, I tried UseShellExecute = true (and RedirectStandardError = false ) and it works. However, I still need to read the result, so it really doesn't help me.

+6
source share
2 answers

Read This MSDN at RedirectStandardError

This seems to be a bit tricky and can slow down if the input or error stream buffers are full. Sit there, waiting for you to read what he wrote ...

+6
source

According to the comments of this answer , in some cases, FFmpeg directly manipulates the screen memory without using standard output streams and errors. One example of this is the [file] already exists. Overwrite? [y/N] prompt [file] already exists. Overwrite? [y/N] [file] already exists. Overwrite? [y/N] [file] already exists. Overwrite? [y/N] .

I assume you ran an external program if .NET to find out what the output is? If it's a tip like the one above, she can pay to avoid trouble and try to provide an argument that will skip it, for example. the -y command, which causes FFmpeg to overwrite the file.

+1
source

Source: https://habr.com/ru/post/901637/


All Articles