Save the Captured Data As MPEG (Delphi 6.0)

1.

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

2.

Add the following line to the end of FormCreate procedure.

   // 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 OnClick event, and code btnSelectCompressorsClick procedure as follows:

procedure TForm1.btnSelectCompressorsClick(Sender: TObject); 
begin
 //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;

5.

Handle the btnSelectMux OnClick 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.

procedure TForm1.btnSelectMuxClick(Sender: TObject); 
begin
 // 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;

6.

Handle the btnSetFrameRate OnClick 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.

procedure TForm1.btnSetFrameRateClick(Sender: TObject); 
begin
   //set rate to 30 fps
 ltmmCaptureCtrl1.UseFrameRate:= True; 
 ltmmCaptureCtrl1.FrameRate:= 30; 
 //you should check with their particular compressor which frame rates are supported. 
end;

7.

Run your program to test it.