How to set audio track when converting images to video slideshow with Image To Video SDK

  • Home
  • /
  • Articles
  • /
  • How to set audio track when converting images to video slideshow with Image To Video SDK

When converting set of JPG, PNG, BMP images to AVI or WMV video slideshow with Image To Video SDK, you can use MP3 or WAV audio track as a background music.

In the sample codes below you can see how MP3 file is applied as a background music for the video slideshow during image to video conversion in VB.NET and C#.

Visual Basic .NET

Imports BytescoutImageToVideoLib
Module Module1
Sub Main()
Console.WriteLine("Converting JPG slides into 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 slide durations
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 background music
converter.ExternalAudioTrackFromFileName = "........bgmusic.mp3"
' Set output video size
converter.OutputWidth = 400
converter.OutputHeight = 300
' Set output video file name
converter.OutputVideoFileName = "result.wmv"
' Run the conversion
Console.WriteLine("Conversion is done. Press any key to continue...")
' Open the result video file in default media player
End Sub
End Module