Movie Maker Timeline Control

VB.NET Developer Getting Started

Assuming that you have already run the Movie Maker Timeline Control Control installation program and started visual studio 2010, the next step is create New Project, select Windows Form Application.

In Toolbox, Right Click mouse and Select Choose Items...  , Select Movie Maker Timeline Control in COM Components Tab.

Now you will see the Movie Maker Timeline Control on Toolbox,  Drag the Movie Maker Timeline Control from Toolbox to form. add button, change text property to "Play" and picturebox on form.

Add following code in Button click event. It will setup the preview window on picturebox.

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

AxTimelineControl1.SetPreviewWnd(PictureBox1.Handle)

End Sub

Add following code in Button click event. It will add video clip and audio clip on timeline control.


Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

Dim strVideo1 As String = "c:\yourfolder\yourfile.mpg"

Dim iVideo1Duration As Double = AxTimelineControl1.GetMediaDuration(strVideo1)

AxTimelineControl1.SetPreviewWnd(PictureBox1.Handle)

AxTimelineControl1.AddVideoClip(AxTimelineControl1.GetVideo1TrackIndex(), strVideo1, 0, iVideo1Duration, 0)

AxTimelineControl1.AddAudioClip(AxTimelineControl1.GetAudio1TrackIndex(), strVideo1, 0, iVideo1Duration, 0, 1)

AxTimelineControl1.Play()

End Sub


Now you can run the sample and click the button to play the timeline.



Finally add another button on form , change the button 1's caption to Play, change button 2's caption to Save.

Add following code in Save Button click event. It will save to MP4 video.

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

AxTimelineControl1.SetVideoTrackResolution(720, 480)

AxTimelineControl1.OutputType = 2

AxTimelineControl1.MP4AspectRatio = 0

AxTimelineControl1.MP4AudioBitrate = 96000

AxTimelineControl1.MP4AudioChannels = 2

AxTimelineControl1.MP4AudioSampleRate = 48000

AxTimelineControl1.MP4Framerate = 25

AxTimelineControl1.MP4H264Preset = 0

AxTimelineControl1.MP4Height = 480

AxTimelineControl1.MP4Width = 720

AxTimelineControl1.MP4VideoBitrate = 1000000

AxTimelineControl1.Save("c:\yourfolder\yourfile.mp4")

End Sub

When conversion completed, it will fired OnConvertCompleted event, Add following code in in OnConvertCompleted.
 

Private Sub AxTimelineControl1_OnConvertCompleted(sender As System.Object, e As System.EventArgs) Handles AxTimelineControl1.OnConvertCompleted

MessageBox.Show("Save Completed")

End Sub

Now run the project, click Play button, then click Save button, you will see the video added to timeline, preview the video and converting the video in same time.