Images to Video in C# and VB.NET with Image to Video SDK - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

Images to Video in C# and VB.NET with Image to Video SDK

  • Home
  • /
  • Articles
  • /
  • Images to Video in C# and VB.NET with Image to Video SDK

Images to video sample shows how to convert image sequence to WMV video file in C# and Visual Basic .NET using Image to Video SDK. Use the source codes below for images to video conversion.

C#

using System;
using System.Diagnostics;
using BytescoutImageToVideo;

namespace SimpleSlideshow
{
class Program
{
 static void Main(string[] args)
 {
 	try
 	{
           	Console.WriteLine("Converting JPG images to video, please wait...");

   // Create BytescoutImageToVideoLib.ImageToVideo object instance
   ImageToVideo converter = new ImageToVideo();

   // Activate the component
   converter.RegistrationName = "demo";
   converter.RegistrationKey = "demo";

   // Add images and set the duration for every slide
   Slide slide;
   slide = converter.AddImageFromFileName("..\..\..\..\slide1.jpg");
   slide.Duration = 3000; // 3000ms = 3s
   slide = converter.AddImageFromFileName("..\..\..\..\slide2.jpg");
   slide.Duration = 3000;
   slide = converter.AddImageFromFileName("..\..\..\..\slide3.jpg");
   slide.Duration = 3000;

   // Set output video size
   converter.OutputWidth = 400;
   converter.OutputHeight = 300;

   // Set output video file name
   converter.OutputVideoFileName = "result.wmv";

   // Run the conversion
   converter.RunAndWait();

   // Release resources
   System.Runtime.InteropServices.Marshal.ReleaseComObject(converter);

   // Open the result video file in default media player
   Process.Start("result.wmv");

         Console.WriteLine("Done. Press any key to continue..");
         Console.ReadKey();
           }
           catch(Exception e)
 	{
               Console.WriteLine("Error: " + e.ToString());
               Console.WriteLine("nPress any key to exit.");
               Console.ReadKey();
           }
 }
}
}

VB.NET

Imports BytescoutImageToVideo

Module Module1

   Sub Main()

       Try
           Console.WriteLine("Converting JPG images to video, please wait...")

           ' Create BytescoutImageToVideoLib.ImageToVideo object instance
           Dim converter As ImageToVideo = New ImageToVideo()

           ' Activate the component
           converter.RegistrationName = "demo"
           converter.RegistrationKey = "demo"

           ' Set default "in" effect for slides (you can also set effects for each single slide)
           converter.Slides.DefaultSlideInEffect = 1 ' teFadeIn (1) - fades in effect for slides transition
           converter.Slides.DefaultSlideInEffectDuration = 500 ' 500 msec for in effect

           ' Add images and set the duration for every slide
           Dim slide As Slide
           slide = CType(converter.AddImageFromFileName("........slide1.jpg"), Slide)
           slide.Duration = 3000 ' 3000ms = 3s
           slide = CType(converter.AddImageFromFileName("........slide2.jpg"), Slide)
           slide.Duration = 3000
           slide = CType(converter.AddImageFromFileName("........slide3.jpg"), Slide)
           slide.Duration = 3000

           ' Set output video size
           converter.OutputWidth = 400
           converter.OutputHeight = 300

           ' Set output video file name
           converter.OutputVideoFileName = "result.wmv"

           ' Run the conversion
           converter.RunAndWait()

           ' Release resources
           System.Runtime.InteropServices.Marshal.ReleaseComObject(converter)

           ' Open the result video file in default media player
           Process.Start("result.wmv")

           Console.WriteLine("Done. Press any key to continue...")
           Console.ReadKey()

       Catch ex As Exception
           Console.WriteLine("Error: " & ex.Message)
           Console.ReadKey()
       End Try
   End Sub

End Module

Tutorials:

prev
next