How to read images to video conversion progress when using 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!

How to read images to video conversion progress when using Image To Video SDK

  • Home
  • /
  • Articles
  • /
  • How to read images to video conversion progress when using Image To Video SDK

Bytescout Image To Video SDK can show conversion progress during images to video conversion.

The VB.NET and C# sample codes below demonstrate how to read conversion progress when you convert JPG, PNG, BMP images to AVI or WMV video with Image To Video SDK.

Visual Basic .NET

Imports System.Diagnostics
Imports System.Threading
Imports BytescoutImageToVideoLib

Class Program
Friend Shared Sub Main(ByVal args As String())

Console.WriteLine("Converting JPG slides into video, please wait..")

' Create BytescoutImageToVideoLib.ImageToVideo object instance
Dim converter As 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 = DirectCast(converter.AddImageFromFileName("........slide1.jpg"), Slide)

slide.Duration = 3000 ' 3000ms = 3s
slide = DirectCast(converter.AddImageFromFileName("........slide2.jpg"), Slide)

slide.Duration = 3000
slide = DirectCast(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"

Console.WriteLine("Conversion started. Hit a key to abort...")

' Run the conversion
converter.Run()

' Show conversion progress:

Dim i As Integer = 0

Dim spin As Char() = New Char() {"|"c, "/"c, "-"c, ""c}

While Not Console.KeyAvailable AndAlso converter.IsRunning
Dim progress As Single = converter.ConversionProgress
Console.WriteLine([String].Format("Converting images {0}% {1}", progress, spin(i)))

Console.CursorTop -= 1
i = i + 1

i = i Mod 4
Thread.Sleep(50)

End While

If converter.IsRunning Then
converter.Stop()

Console.WriteLine("Conversion aborted by user.")
Else
Console.WriteLine("Conversion competed successfully.")

End If

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

Console.WriteLine()
Console.WriteLine("Hit any key...")
Console.ReadKey()

End Sub
End Class 

Visual C#

using System;

using System.Diagnostics;
using System.Threading;
using BytescoutImageToVideoLib;

namespace ConversionProgress
{
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";

Console.WriteLine("Conversion started. Hit a key to abort...");

// Run the conversion
converter.Run();

// Show conversion progress:

int i = 0;
char[] spin = new char[] { '|', '/', '-', '\' };

while (!Console.KeyAvailable && converter.IsRunning)
{

float progress = converter.ConversionProgress;
Console.WriteLine(String.Format("Converting images {0}% {1}", progress, spin[i++]));

Console.CursorTop--;
i %= 4;
Thread.Sleep(50);

}

if (converter.IsRunning)
{
converter.Stop();

Console.WriteLine("Conversion aborted by user.");
}
else

{
Console.WriteLine("Conversion competed successfully.");
}

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

Console.WriteLine();

Console.WriteLine("Hit any key...");
Console.ReadKey();

}
}
} 

Tutorials:

prev
next