C# ffmpeg 视频处理

ffmpeg的官网:https://ffmpeg.org/

ffmpeg是一个强大的视频处理软件(控制台程序),可以通过C# 调用ffmpeg,并传入指令参数,即可实现视频的编辑。

/// <summary>
/// 设置ffmpeg.exe的路径
/// </summary>
static string FFmpegPath = @"C:\Users\Downloads\ffmpeg-20180613-67747c8-win64-static\bin\ffmpeg.exe";

static void Main(string[] args)
{
string videoUrl = @"D:\video\Wildlife.wmv";
string targetUrl = @"D:\video\newFile.mp4";

//视频转码
string para = string.Format("-i {0} -b 1024k -acodec copy -f mp4 {1}", videoUrl, targetUrl);
RunMyProcess(para);

Console.WriteLine("完成!");
Console.ReadKey();
}

static void RunMyProcess(string Parameters)
{
var p = new Process();
p.StartInfo.FileName = FFmpegPath;
p.StartInfo.Arguments = Parameters;
//是否使用操作系统shell启动
p.StartInfo.UseShellExecute = false;
//不显示程序窗口
p.StartInfo.CreateNoWindow = true;
p.Start();
Console.WriteLine("\n开始转码...\n");
p.WaitForExit();
p.Close();
}


合并视频
string para = string.Format(" -f concat -safe 0 -i {0} -c copy {1}", @"D:\video\filelist.txt", @"D:\video\c.mp4");
filelist.txt的内容:

file 'D:\video\input1.mp4'
file 'D:\video\input2.mp4'


原文链接https://blog.csdn.net/cctvcqupt/article/details/80695879?utm_source=blogxgwz0

posted @ 2019-09-28 09:40  龙骑科技  阅读(8652)  评论(0编辑  收藏  举报