ByteScout Image To Video SDK - VB.NET - 2x Speed by Parallel Generation - ByteScout

ByteScout Image To Video SDK – VB.NET – 2x Speed by Parallel Generation

  • Home
  • /
  • Articles
  • /
  • ByteScout Image To Video SDK – VB.NET – 2x Speed by Parallel Generation

2x speed by parallel generation in VB.NET with ByteScout Image To Video SDK

Write code in VB.NET to make 2x speed by parallel generation with this How-To tutorial

Every ByteScout tool contains example VB.NET source codes that you can find here or in the folder with installed ByteScout product. ByteScout Image To Video SDK was made to help with 2x speed by parallel generation in VB.NET. ByteScout Image To Video SDK is the software development kit that can take a set of images and generate video slide show from them. Includes built-in support for 100+ of 2-D and 3-D slide transitions effects. Supports output in WMV, AVI, WEBM video formats.

VB.NET code snippet like this for ByteScout Image To Video SDK works best when you need to quickly implement 2x speed by parallel generation in your VB.NET application. To do 2x speed by parallel generation in your VB.NET project or application you may simply copy & paste the code and then run your app! Code testing will allow the function to be tested and work properly with your data.

Trial version can be obtained from our website for free. It includes this and other source code samples for VB.NET.

Try it today: Get 60 Day Free Trial or sign up for Web API

MultiThreadProcessing.VS2005.vbproj
      
<?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>8.0.50727</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{CA162738-16E9-4504-B5A6-A6C5F58F804E}</ProjectGuid> <OutputType>Exe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>MultiThreadProcessing</RootNamespace> <AssemblyName>MultiThreadProcessing</AssemblyName> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG,TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Import Include="Microsoft.VisualBasic" /> <Import Include="System" /> </ItemGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Program.vb" /> <Compile Include="Properties\AssemblyInfo.vb" /> </ItemGroup> <ItemGroup> <COMReference Include="BytescoutImageToVideo"> <Guid>{5212739C-A95B-4CDA-B116-F540A549B648}</Guid> <VersionMajor>1</VersionMajor> <VersionMinor>0</VersionMinor> <Lcid>0</Lcid> <WrapperTool>tlbimp</WrapperTool> <Isolated>False</Isolated> <EmbedInteropTypes>True</EmbedInteropTypes> </COMReference> <COMReference Include="stdole"> <Guid>{00020430-0000-0000-C000-000000000046}</Guid> <VersionMajor>2</VersionMajor> <VersionMinor>0</VersionMinor> <Lcid>0</Lcid> <WrapperTool>primary</WrapperTool> <Isolated>False</Isolated> </COMReference> </ItemGroup> <ItemGroup> <Content Include="slide1.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide2.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide3.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide4.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide5.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide6.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> <ItemGroup> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.Targets" /> </Project>

Try it today: Get 60 Day Free Trial or sign up for Web API

MultiThreadProcessing.VS2008.vbproj
      
<?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="3.5"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>9.0.21022</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{CA162738-16E9-4504-B5A6-A6C5F58F804E}</ProjectGuid> <OutputType>Exe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>MultiThreadProcessing</RootNamespace> <AssemblyName>MultiThreadProcessing</AssemblyName> <OldToolsVersion>2.0</OldToolsVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG,TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Import Include="Microsoft.VisualBasic" /> <Import Include="System" /> </ItemGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Program.vb" /> <Compile Include="Properties\AssemblyInfo.vb" /> </ItemGroup> <ItemGroup> <COMReference Include="BytescoutImageToVideo"> <Guid>{5212739C-A95B-4CDA-B116-F540A549B648}</Guid> <VersionMajor>1</VersionMajor> <VersionMinor>0</VersionMinor> <Lcid>0</Lcid> <WrapperTool>tlbimp</WrapperTool> <Isolated>False</Isolated> <EmbedInteropTypes>True</EmbedInteropTypes> </COMReference> <COMReference Include="stdole"> <Guid>{00020430-0000-0000-C000-000000000046}</Guid> <VersionMajor>2</VersionMajor> <VersionMinor>0</VersionMinor> <Lcid>0</Lcid> <WrapperTool>primary</WrapperTool> <Isolated>False</Isolated> </COMReference> </ItemGroup> <ItemGroup> <Content Include="slide1.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide2.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide3.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide4.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide5.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide6.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> <ItemGroup> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.Targets" /> </Project>

Try it today: Get 60 Day Free Trial or sign up for Web API

MultiThreadProcessing.VS2010.vbproj
      
<?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion> </ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{CA162738-16E9-4504-B5A6-A6C5F58F804E}</ProjectGuid> <OutputType>Exe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>MultiThreadProcessing</RootNamespace> <AssemblyName>MultiThreadProcessing</AssemblyName> <OldToolsVersion>3.5</OldToolsVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG,TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Import Include="Microsoft.VisualBasic" /> <Import Include="System" /> </ItemGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Program.vb" /> <Compile Include="Properties\AssemblyInfo.vb" /> </ItemGroup> <ItemGroup> <COMReference Include="BytescoutImageToVideo"> <Guid>{5212739C-A95B-4CDA-B116-F540A549B648}</Guid> <VersionMajor>1</VersionMajor> <VersionMinor>0</VersionMinor> <Lcid>0</Lcid> <WrapperTool>tlbimp</WrapperTool> <Isolated>False</Isolated> <EmbedInteropTypes>True</EmbedInteropTypes> </COMReference> <COMReference Include="stdole"> <Guid>{00020430-0000-0000-C000-000000000046}</Guid> <VersionMajor>2</VersionMajor> <VersionMinor>0</VersionMinor> <Lcid>0</Lcid> <WrapperTool>primary</WrapperTool> <Isolated>False</Isolated> </COMReference> </ItemGroup> <ItemGroup> <Content Include="slide1.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide2.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide3.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide4.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide5.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> <Content Include="slide6.jpg"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> </ItemGroup> <ItemGroup> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.Targets" /> </Project>

Try it today: Get 60 Day Free Trial or sign up for Web API

Program.vb
      
' You can speed up the conversion using the following technique: ' 1) Generate video parts in parallel threads; ' 2) Combine these parts into final video. ' Let us say you have 20 slides. ' Then you can run a thread to convert 1-10 slides and another one to convert 11-20 slides. ' Finally combine these parts into a single one using .JoinWMVFiles(part1, part2, output) ' or .JoingAVIFiles(part1, part2, output) functions. Imports System.Diagnostics Imports System.Runtime.InteropServices Imports System.Threading Imports BytescoutImageToVideo Class ThreadData Public InputFiles As String() Public OutputFile As String Public Sub New(ByVal inputFiles As String(), ByVal outputFile As String) Me.InputFiles = inputFiles Me.OutputFile = outputFile End Sub End Class Class Program Private Shared NumBusy As Integer Private Shared DoneEvent As ManualResetEvent Friend Shared Sub Main(ByVal args As String()) DoneEvent = New ManualResetEvent(False) NumBusy = 2 ' variable to store video file extension Dim videoFileExt As String ' are we using WMV or AVI video format for output Dim isWMV As Boolean = False ' if is WMV then use .wmv extension If isWMV Then videoFileExt = ".wmv" Else ' else use AVI videoFileExt = ".avi" End If ' Start two conversion threads Console.WriteLine("Start first thread...") Dim threadData1 As New ThreadData(New String() {"slide1.jpg", "slide2.jpg", "slide3.jpg"}, "Part1" & videoFileExt) ThreadPool.QueueUserWorkItem(AddressOf DoWork, threadData1) Console.WriteLine("Start second thread...") Dim threadData2 As New ThreadData(New String() {"slide4.jpg", "slide5.jpg", "slide6.jpg"}, "Part2" & videoFileExt) ThreadPool.QueueUserWorkItem(AddressOf DoWork, threadData2) ' Wait for both threads finished DoneEvent.WaitOne() ' Join generates parts Console.WriteLine("Join parts into the final video file...") Dim converter As New ImageToVideo() If isWMV Then converter.JoinWMVFiles("Part1" & videoFileExt, "Part2" & videoFileExt, "Result" & videoFileExt) Else converter.JoinAVIFiles("Part1" & videoFileExt, "Part2" & videoFileExt, "Result" & videoFileExt) End If ' Open the output video file in default media player Process.Start("Result" & videoFileExt) Console.WriteLine("Done. Press any key to continue...") Console.ReadKey() End Sub Private Shared Sub DoWork(ByVal data As Object) Dim threadData As ThreadData = DirectCast(data, ThreadData) Try ' Create BytescoutImageToVideoLib.ImageToVideo object instance Dim converter As New ImageToVideo() ' Activate the component converter.RegistrationName = "demo" converter.RegistrationKey = "demo" ' Add slides For Each file As String In threadData.InputFiles Dim slide As Slide = converter.AddImageFromFileName(file) slide.Duration = 3000 ' 3000ms = 3s slide.Effect = SlideEffectType.seEaseIn Next ' Set output video size converter.OutputWidth = 640 converter.OutputHeight = 480 ' Set output video file name converter.OutputVideoFileName = threadData.OutputFile ' Run the conversion converter.RunAndWait() ' Release resources Marshal.ReleaseComObject(converter) Console.WriteLine("Thread finished.") Catch ex As Exception Console.WriteLine(ex.Message) End Try If Interlocked.Decrement(NumBusy) = 0 Then DoneEvent.Set() End If End Sub End Class

Try it today: Get 60 Day Free Trial or sign up for Web API

MORE INFORMATION

Get 60 Day Free Trial or Visit ByteScout Image To Video SDK page

Explore ByteScout Image To Video SDK documentation

WEB API VERSION

Sign Up for free Web API key

Explore Web API Documentation

Tutorials:

prev
next