开发者

Execute ffmpeg command with C#

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 < 开发者_Python百科/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.


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


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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜