unit1.pas

来自「为Delphi2005做了改动 DSPack 2.3.3 (Sep 2004).」· PAS 代码 · 共 70 行

PAS
70
字号
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DSPack, DSUtil, StdCtrls, DirectShow9;

type
  TForm1 = class(TForm)
    FilterGraph: TFilterGraph;
    DivXEncoder: TFilter;
    OpenDialog: TOpenDialog;
    GO: TButton;
    Output: TEdit;
    FileSource: TFilter;
    Label1: TLabel;
    Memo1: TMemo;
    MP3Enc: TFilter;
    procedure GOClick(Sender: TObject);
    procedure FilterGraphDSEvent(sender: TComponent; Event, Param1,
      Param2: Integer);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  private
    { D閏larations priv閑s }
  public
    { D閏larations publiques }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.GOClick(Sender: TObject);
var Filter: IBaseFilter;
    FileSink: IFileSinkFilter;
begin
  FilterGraph.Active := true;
  with FilterGraph as ICaptureGraphBuilder2 do
    begin
      SetOutputFileName(MEDIASUBTYPE_Avi, StringToOleStr(Output.Text), Filter, FileSink);
      ShowFilterPropertyPage(Self.Handle, DivXEncoder as IBaseFilter, ppVFWCompConfig);
      OpenDialog.Title := 'Select Video File';
      if OpenDialog.Execute then
      begin
        with FileSource as IFileSourceFilter do Load(StringToOleStr(OpenDialog.FileName), nil);
        RenderStream(nil, nil, FileSource as IBaseFilter, DivXEncoder as IBaseFilter, Filter);
        RenderStream(nil, nil, FileSource as IBaseFilter, DivXEncoder as IBaseFilter, Filter);
        FilterGraph.Play;
      end;
    end;
end;

procedure TForm1.FilterGraphDSEvent(sender: TComponent; Event, Param1,
  Param2: Integer);
begin
  memo1.Lines.Add(GetEventCodeDef(Event))
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  FilterGraph.ClearGraph;
  FilterGraph.Active := false;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?