Unit1.pas 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. unit Unit1;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, 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éclarations privées }
  23. public
  24. { Déclarations 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. begin
  34. FilterGraph.Active := true;
  35. with FilterGraph as ICaptureGraphBuilder2 do
  36. begin
  37. SetOutputFileName(MEDIASUBTYPE_Avi, StringToOleStr(Output.Text), Filter, FileSink);
  38. ShowFilterPropertyPage(Self.Handle, DivXEncoder as IBaseFilter, ppVFWCompConfig);
  39. OpenDialog.Title := 'Select Video File';
  40. if OpenDialog.Execute then
  41. begin
  42. with FileSource as IFileSourceFilter do Load(StringToOleStr(OpenDialog.FileName), nil);
  43. RenderStream(nil, nil, FileSource as IBaseFilter, DivXEncoder as IBaseFilter, Filter);
  44. RenderStream(nil, nil, FileSource as IBaseFilter, DivXEncoder as IBaseFilter, Filter);
  45. FilterGraph.Play;
  46. end;
  47. end;
  48. end;
  49. procedure TForm1.FilterGraphDSEvent(sender: TComponent; Event, Param1,
  50. Param2: Integer);
  51. begin
  52. memo1.Lines.Add(GetEventCodeDef(Event))
  53. end;
  54. procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  55. begin
  56. FilterGraph.ClearGraph;
  57. FilterGraph.Active := false;
  58. end;
  59. end.