fauvent fauvent - 2 months ago 35
C# Question

Working with FFMPEG / Splicer and C#

I have been trying to develop a C# app for a long time now which is intended to run on a server. It takes info from a data base and makes a video with it. I have been using libraries for that porpuse (Aforge). But now it looks like I HAVE to use FFMPEG to combine 5 mp4 in one. My question would be:


  1. Do I have to "execute" the exe file from the download to make it work? Or I can simply use the dll like the other libraries (like Aforge)?

  2. FFMPEG looks very complicated to me. I have been trying to use Splicer insted. There is a very nice and clean example that I would love to use. But I can't get Splicer to work. I am using VS 13. How exaclty I get Splicer working? Adding the dlls to the "debug folder" then just adding the reference? If so which dlls?



This is my code so far. It does not show any errors but it does not do anything (I added the reference and the splicer.dll to my project)

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();
}
}

}
}
}


Thanks in advance!

Answer

So I have been working on this and I would like to post an answer on my question, which wasn't exactly popular.

  1. You don't have to execute the exe or add any dll reference to get ffmpeg going, you simply executed the unziped exe through the command line, like this:

    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();
    
    1. FFMPEG is not complicated, you just need to read a little bit of documentation and see some examples. There is a lot of information and sample codes in the web.