Click here to Skip to main content
15,745,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Is there any way to merge two video in C#.

Merging - like video 2 is appended to video 1

have tried by file appending ,FFMPEG but did not get the result.

Please provide any code which can show the way.

I am using encoder to creating the video.

This is possible but the two videos MUST have the same properties (frame rate, resolution...etc). If they don't, you will have to convert one of them to be compatible with the other.
I have found the following example that does this:
Merge videos[^]
Hope it is useful.
Share this answer
You can use splicer

public static void MergeVideosWithSplicer(string outputVideoPath, string firstVideoFilePath, string secondVideoFilePath)
if (File.Exists(outputVideoPath))
using (ITimeline timeline = new DefaultTimeline())
double overlayEffectLength = 30;
// greate our default audio track

// add a video group, 32bpp, 320x240 (32bpp required to allow for an alpha channel)
IGroup videoGroup = timeline.AddVideoGroup(32, 640, 480);

// add our default video track
videoGroup.AddTrack();//.AddImage(Resources.watermark, InsertPosition.Absolute, 0, 2, 10);

// to the first audio track.
IAudioVideoClipPair firstVideoPair = timeline.AddVideoWithAudio(firstVideoFilePath);
videoGroup.AddEffect(firstVideoPair.VideoClip.Duration - (overlayEffectLength / 2), overlayEffectLength,
new EffectDefinition(StandardEffects.MirrorAndGrayscaleEffect));

IAudioVideoClipPair secondVideoPair = timeline.AddVideoWithAudio(secondVideoFilePath);

//IClip clip = videoGroup.AddTrack().AddImage(Resources.watermark, secondVideoPair.VideoClip.Offset, secondVideoPair.VideoClip.Duration + secondVideoPair.VideoClip.Offset);
//clip.StretchMode = ResizeFlags.Crop;


//using (var renderer = new AviFileRenderer(timeline, outputVideoPath /*, WindowsMediaProfiles.HighQualityVideo */ ))
using (var renderer = new WindowsMediaRenderer(timeline, outputVideoPath, WindowsMediaProfiles.HighQualityVideo))

Share this answer
Member 10876869 7-May-15 6:11am    
Am getting error like this, please help me on this
Exception Details: System.Runtime.InteropServices.COMException: The parameter is incorrect.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900