This sample source code demonstrates how to convert set of JPG, PNG, BMP images to AVI or WMV video files in Visual C# using Image To Video SDK.
Bytescout Image to Video SDK provides set of methods and properties accessible from .NET applications to convert images to video file.
using System;
using System.Diagnostics;
using BytescoutImageToVideoLib;
namespace SimpleSlideshow
{
class Program
{
static void Main(string[] args)
{
Console.Write("Converting JPG slides into 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 = (Slide) converter.AddImageFromFileName("..\..\..\..\slide1.jpg");
slide.Duration = 3000; // 3000ms = 3s
slide = (Slide) converter.AddImageFromFileName("..\..\..\..\slide2.jpg");
slide.Duration = 3000;
slide = (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();
Console.WriteLine("Conversion is done. Press any key to continue..");
Console.ReadKey();
// Open the result video file in default media player
Process.Start("result.wmv");
}
}
}