Save the Captured Data As MPEG (Visual Basic)

1.

Start with the project that you created in My First Capture.

2.

Add the following line to the end of Form_Load Sub.

   'Set the Target or Output file. 
   ltmmCaptureCtrl1.TargetFile = "c:\target.avi"

3.

Add 3 button controls to your form, and name them as follows:

 

Name

Caption

 

btnSelectCompressors

Select MPEG Compressors

 

btnSelectMux

Select Multiplexer

 

btnSetFrameRate

Set Frame Rate

4.

Handle the btnSelectCompressors Click event, and code btnSelectCompressors_Click Sub as follows:

      Private Sub btnSelectCompressors_Click()
   'select the MS MPEG-4 Video Codec
   ltmmCaptureCtrl1.VideoCompressors.Selection = ltmmCaptureCtrl1.VideoCompressors.Find("@device:sw:{33D9A760-90C8-11D0-BD43-00A0C911CE86}\Microsoft MPEG-4 Video Codec V2")
   'select the MP3 audio video compressor
   ltmmCaptureCtrl1.AudioCompressors.Selection = ltmmCaptureCtrl1.AudioCompressors.Find("@device:cm:{33D9A761-90C8-11D0-BD43-00A0C911CE86}\85MPEG Layer-3")
End Sub

5.

Handle the btnSelectMux Click event, and code btnSelectMuxClick procedure as follows. Note that you should set the MPEG multiplexer, this example will use an AVI multiplexer because it is available on all computers. But you should use a real MPEG multiplexer.

Private Sub btnSelectMux_Click()
   ' assign the required Mux
   ' this case: AVI
   ltmmCaptureCtrl1.TargetFormats.Item (1).Mux = "@device:sw:{083863F1-70DE-11D0-BD40-00A0C911CE86}\{E2510970-F137-11CE-8B67-00AA00A3F1A6}"
   ' assign the optional SinkSubType
   ' this case: MEDIASUBTYPE_Avi
   ltmmCaptureCtrl1.TargetFormats.Item (1).SinkSubType = "{E436EB88-524F-11CE-9F53-0020AF0BA770}"
   ' assign an optional Sink
   ' this case: default
   ltmmCaptureCtrl1.TargetFormats.Item (1).Sink = ""
End Sub 

6.

Handle the btnSetFrameRate Click event, and code btnSetFrameRateClick procedure as follows; you should set a frame rate supported by MPEG. Look at the documentation for your MPEG multiplexer to see which frame rates it supports. Common frame rates are: 23.976, 24, 25, 29.97, 30fps.

Private Sub btnSetFrameRate_Click()
   'set rate to 30 fps
   ltmmCaptureCtrl1.UseFrameRate = True
   ltmmCaptureCtrl1.FrameRate = 30
   'you should check with their particular compressor which frame rates are supported. 
End Sub

7.

Run your program to test it.