C# ffmpeg 視頻處理格式轉換
C# ffmpeg 視頻處理格式轉換avi到MP4格式
1、代碼如下:
using System;
using System.Diagnostics;
namespace LongtengSupremeConsole
{
class Program
{
static void Main(string[] args)
{
string para = $"ffmpeg -i 123.avi 11233.mp4";
RunProcess(para);
Console.WriteLine("完成!");
Console.ReadKey();
}
static void RunProcess(string Parameters)
{
var p = new Process();
p.StartInfo.FileName = "CMD";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.Arguments = Parameters;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine(Parameters);
Console.WriteLine("\n開始轉碼...\n");
//p.WaitForExit();
// p.Close();
}
}
}
2、首先debug生成Debug,然后把下載的ffmpeg.exe(可以到https://ffmpeg.org/download.html下載,)拷貝到Debug下,直接運行程序就可以了
3、運行效果如下:
4、ffmpeg下載
第一種: https://ffmpeg.org/download.html,可以看到源碼和build版本
第二種:https://ffmpeg.zeranoe.com/builds/,直接下載編譯版本