Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge 2 video files together in C#?

Tags:

c#

merge

video

asf

I need to merge multiple video files (.wmv) together to get a single wmv file. How can I do it?

like image 728
Thilina H Avatar asked Jul 31 '11 16:07

Thilina H


2 Answers

You can do that easily Use Splicer, it free and open source in C#

Simplify developing applications for editing and encoding audio and video using DirectShow

Example:

using Splicer;
using Splicer.Timeline;
using Splicer.Renderer;

string firstVideoFilePath = @"C:\first.avi";
string secondVideoFilePath = @"C:\second.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();
    }
}
like image 52
Jalal Said Avatar answered Nov 14 '22 21:11

Jalal Said


You can split and join video files using DirectShow or the Windows Media Encoder.

DirectShowNet library has examples which you might find useful. I think its called DESCombine.

like image 23
Neil Knight Avatar answered Nov 14 '22 22:11

Neil Knight