Unit1.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit Unit1;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  5.   Dialogs, DSPack, DSUtil, StdCtrls, DirectShow9;
  6. type
  7.   TForm1 = class(TForm)
  8.     FilterGraph: TFilterGraph;
  9.     DivXEncoder: TFilter;
  10.     OpenDialog: TOpenDialog;
  11.     GO: TButton;
  12.     Output: TEdit;
  13.     FileSource: TFilter;
  14.     Label1: TLabel;
  15.     Memo1: TMemo;
  16.     MP3Enc: TFilter;
  17.     procedure GOClick(Sender: TObject);
  18.     procedure FilterGraphDSEvent(sender: TComponent; Event, Param1,
  19.       Param2: Integer);
  20.     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  21.   private
  22.     { D閏larations priv閑s }
  23.   public
  24.     { D閏larations publiques }
  25.   end;
  26. var
  27.   Form1: TForm1;
  28. implementation
  29. {$R *.dfm}
  30. procedure TForm1.GOClick(Sender: TObject);
  31. var Filter: IBaseFilter;
  32.     FileSink: IFileSinkFilter;
  33.     CaptureGraph: ICaptureGraphBuilder2;
  34.     DivXFilter: IBaseFilter;
  35.     FileSourceFilter: IFileSourceFilter;
  36.     SourceFilter: IBaseFilter;
  37. begin
  38.   FilterGraph.Active := true;
  39.   FilterGraph.QueryInterface(ICaptureGraphBuilder2, CaptureGraph);
  40.   DivXEncoder.QueryInterface(IBaseFilter, DivXFilter);
  41.   CaptureGraph.SetOutputFileName(MEDIASUBTYPE_Avi, StringToOleStr(Output.Text), Filter, FileSink);
  42.   ShowFilterPropertyPage(Self.Handle, DivXFilter, ppVFWCompConfig);
  43.   OpenDialog.Title := 'Select Video File';
  44.   if OpenDialog.Execute then
  45.   begin
  46.     FileSource.QueryInterface(IFileSourceFilter, FileSourceFilter);
  47.     FileSourceFilter.Load(StringToOleStr(OpenDialog.FileName), nil);
  48.     FileSource.QueryInterface(IBaseFilter, SourceFilter);
  49.     CaptureGraph.RenderStream(nil, nil, SourceFilter, DivXFilter, Filter);
  50.     CaptureGraph.RenderStream(nil, nil, SourceFilter, DivXFilter, Filter);
  51.     FilterGraph.Play;
  52.   end;
  53. end;
  54. procedure TForm1.FilterGraphDSEvent(sender: TComponent; Event, Param1,
  55.   Param2: Integer);
  56. begin
  57.   memo1.Lines.Add(GetEventCodeDef(Event))
  58. end;
  59. procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  60. begin
  61.   FilterGraph.ClearGraph;
  62.   FilterGraph.Active := false;
  63. end;
  64. end.