5

Hi can someone show me how you would execute the following command against FFmpeg in C#.

mkfifo temp1.a
mkfifo temp1.v
mkfifo temp2.a
mkfifo temp2.v
mkfifo all.a
mkfifo all.v
ffmpeg -i input1.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null &
ffmpeg -i input2.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null &
ffmpeg -i input1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null &
{ ffmpeg -i input2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; } &
cat temp1.a temp2.a > all.a &
cat temp1.v temp2.v > all.v &
ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \
       -f yuv4mpegpipe -i all.v \
       -sameq -y output.flv
rm temp[12].[av] all.[av]

Thank you in advance.

Greg B
  • 14,597
  • 18
  • 87
  • 141
Paul
  • 51
  • 1
  • 2

2 Answers2

2

You can download the executable files of ffmpeg from the official site and place them in your application startup path and then eecute them using the Process.Start() and after then pass on the arguments to that according to your needs.

Example:-

exe path- ffprobe.exe -hide_banner -show_format -show_streams -pretty {video_file}

private static string Execute(string exePath, string parameters)
{
string result = String.Empty;

using (Process p = new Process())
{
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.CreateNoWindow = true;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.FileName = exePath;
    p.StartInfo.Arguments = parameters;
    p.Start();
    p.WaitForExit();

    result = p.StandardOutput.ReadToEnd();
}

return result;
}
2

You can use Process.Start method from System.Diagnostics namespace.

Greg B
  • 14,597
  • 18
  • 87
  • 141
Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
  • Hi Greg, thanks for getting back to me. I know how to execute the the exe file. The problem i have is that I dont understand how to execute the commands, do you execute it as 1 argument to the exe file or do split up the arguments and call the exe multiple times. That is what i am stuck on. – Paul Jan 20 '11 at 17:31