C#使用ffmpeg抽帧压缩mp4

1.ffmpeg官网

http://ffmpeg.org/ffmpeg.html#Video-Options

/*
 * WinForm例子
 */
 
 static string FFmpegPath = System.AppDomain.CurrentDomain.BaseDirectory + "ffmpeg.exe";
 
 static void RunMyProcess(string Parameters)
{
	var p = new Process();
	p.StartInfo.FileName = FFmpegPath;
        p.StartInfo.Arguments = Parameters;
        p.StartInfo.UseShellExecute = false;//是否使用操作系统shell启动
        p.StartInfo.CreateNoWindow = true;//不显示程序窗口
        p.Start();
        Console.WriteLine("\n开始抽帧...\n");
        p.WaitForExit();
        p.Close();
}

private void button1_Click_1(object sender, EventArgs e)
{
	string para = string.Format(" -i {0} -r 2 -vcodec libx264 -preset:v fast -crf 36 {1}", sVideoFileNameGlobal, "D:\\1.mp4");
        RunMyProcess(para);
}

2.经测试,38M的mp4可压缩为1M,用时20秒

在这里插入图片描述

你可能感兴趣的:(C#)