# How to add the transition between 2 video fragments?

Video Edit SDK .Net

In this article, we add a simple transition between 2 video files (parts of them).

# Add 2 video fragments from 2 video files, each 5 seconds (5000 ms) long

The first fragment is located in the first 5 seconds on the timeline, and the second fragment is located between 4 and 9 seconds, so the second video overlaps the first video. This 1-second overlap will be used as a transition between videos. Each transition except fade-in/out requires this.

string[] files = { @"c:\samples\video1.avi", @"c:\samples\video2.avi" };
var videoFile = new VideoSource(
        files[0],
        TimeSpan.Zero,
        TimeSpan.FromMilliseconds(5000),
        VideoEditStretchMode.Letterbox,
        0,
        1.0);

var videoFile2 = new VideoSource(
        files[1],
        TimeSpan.Zero,
        TimeSpan.FromMilliseconds(5000),
        VideoEditStretchMode.Letterbox,
        0,
        1.0);

await VideoEdit1.Input_AddVideoFileAsync(
        videoFile,
        TimeSpan.FromMilliseconds(0));

await VideoEdit1.Input_AddVideoFileAsync(
        videoFile2,
        TimeSpan.FromMilliseconds(4000));
string[] files = { @"c:\samples\video1.avi", @"c:\samples\video2.avi" };
var videoFile = new VideoFileSource(
        files[0],
        TimeSpan.Zero,
        TimeSpan.FromMilliseconds(5000),
        0,
        1.0);

var videoFile2 = new VideoFileSource(
        files[1],
        TimeSpan.Zero,
        TimeSpan.FromMilliseconds(5000),
        0,
        1.0);

VideoEdit1.Input_AddVideoFile(
        videoFile,
        TimeSpan.FromMilliseconds(0));

VideoEdit1.Input_AddVideoFile(
        videoFile2,
        TimeSpan.FromMilliseconds(4000));

# Add a transition between 4 and 5 seconds on the timeline

Get the ID of the required transition.

int id = VideoEdit.Video_Transition_GetIDFromName("Upper right");

Add the transition by specifying the start and stop times and the transition ID.

VideoEdit1.Video_Transition_Add(TimeSpan.FromMilliseconds(4000), TimeSpan.FromMilliseconds(5000), id);

Transition names are available using the "VideoEdit.Video_Transition_Names()" call. Also, you can check the IDs list in this article.

List all available transitions.

var transitionNames = VideoEdit1.Video_Transitions_Names();
var transitionName = transitionNames[10];

Add the transition by name.

var trans = new VideoTransition(
        transitionName,
        TimeSpan.FromMilliseconds(4000),
        TimeSpan.FromMilliseconds(5000));
VideoEdit1.Video_Transitions.Add(trans);

# Required redists

  • Video Edit SDK redist x86 x64

How can the required redists be installed or deployed to the user's PC?


Visit our GitHub page to get more code samples.