ffmpeg的官网:https://ffmpeg.org/
ffmpeg是一个强大的视频处理软件(控制台程序),可以通过C# 调用ffmpeg,并传入指令参数,即可实现视频的编辑。
/// <summary>
/// 设置ffmpeg.exe的路径
/// </summary>
static string FFmpegPath = @"C:UsersDownloadsffmpeg-20180613-67747c8-win64-staticinffmpeg.exe";
static void Main(string[] args)
{
string videoUrl = @"D:videoWildlife.wmv";
string targetUrl = @"D:video
ewFile.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("
开始转码...
");
p.WaitForExit();
p.Close();
}
合并视频
string para = string.Format(" -f concat -safe 0 -i {0} -c copy {1}", @"D:videofilelist.txt", @"D:videoc.mp4");
filelist.txt的内容:
file 'D:videoinput1.mp4'
file 'D:videoinput2.mp4'
原文链接https://blog.csdn.net/cctvcqupt/article/details/80695879?utm_source=blogxgwz0