工作与FFMPEG / Splicer和c#
本文关键字:Splicer FFMPEG 工作 | 更新日期: 2023-09-27 18:08:41
我一直在尝试开发一个c#应用程序很长一段时间了,现在打算在服务器上运行。它从数据库中获取信息,并用它制作视频。为此,我一直在使用库(Aforge)。但是现在看起来我必须使用FFMPEG将5个mp4合并在一起。我的问题是:
-
我是否必须"执行"从下载的exe文件,使其工作?或者我可以简单地使用dll像其他库(如Aforge)?
-
FFMPEG在我看来非常复杂。我一直在尝试使用Splicer代替。有一个非常好的和干净的例子,我想使用。但我没法让Splicer工作。我使用VS 13。我是如何让Splicer工作的?添加dll到"调试文件夹",然后只是添加引用?如果是这样,那是什么?
这是我到目前为止的代码。它不显示任何错误,但它不做任何事情(我添加了引用和splicer.dll到我的项目)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Splicer;
using Splicer.Renderer;
using Splicer.Timeline;
namespace MergeVideos
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string firstVideoFilePath = @"C:'file1.avi";
string secondVideoFilePath = @"C:'file2.avi";
string outputVideoPath = @"C:'output.avi";
using (ITimeline timeline = new DefaultTimeline())
{
IGroup group = timeline.AddVideoGroup(32, 720, 576);
var firstVideoClip = group.AddTrack().AddVideo(firstVideoFilePath);
var secondVideoClip = group.AddTrack().AddVideo(secondVideoFilePath, firstVideoClip.Duration);
using (AviFileRenderer renderer = new AviFileRenderer(timeline, outputVideoPath))
{
renderer.Render();
}
}
}
}
}
提前感谢!
所以我一直在做这个,我想发表一个我的问题的答案,这不是很受欢迎。
-
您不需要执行exe或添加任何dll引用来运行ffmpeg,您只需通过命令行执行解压缩的exe,如下所示:
var p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = "/k ffmpeg -f concat -i mylist.txt -c copy output"; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.Start();
- FFMPEG并不复杂,您只需要阅读一点点文档并查看一些示例。web上有很多信息和示例代码。