I worte some code to run ffmpeg, to have full control of it, I use pipe to handle its input and output, the input and output code snippets are as shown below: