用WINDOWS MEDIA SDK中的WMEncSDK9进行视频流压缩,为什么在VB、VC中好使,转到DELPHI中就坏菜了呢?(100分)

  • 主题发起人 主题发起人 andriy
  • 开始时间 开始时间
A

andriy

Unregistered / Unconfirmed
GUEST, unregistred user!
我用图象采集卡采集视频流,然后用WMENCSDK进行压缩,为什么在VB中好用,而在DELPHI中就执行不过去了呢,欢迎这方面的高手来指教、灌水!
是否是DELPHI的先天不足,怎么解决?
VB代码:(好用)在引用中加入 windows media encoder 和windows media endcoder preview control
[red]Private Sub Command1_Click()
Dim lPreviewStream As Long
Dim lPostviewStream As Long
Set Encoder = New WMEncoder
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcAud As IWMEncSource
Dim SrcVid As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim File As IWMEncFile
Set Encoder = New WMEncoder
Set SrcGrpColl = Encoder.SourceGroupCollection
Set SrcGrp = SrcGrpColl.Add("SG_1")
Set File = Encoder.File
File.LocalFileName = "C:/test.wmv"
Encoder.EnableAutoArchive = True

Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set ProColl = Encoder.ProfileCollection
SrcGrp.Profile = ProColl.Item(2)
SrcVid.SetInput "FILE://c:/lake.mpg"
SrcAud.SetInput "FILE://c:/lake.mpg"
SrcVid.Repeat = False
SrcAud.Repeat = False
Encoder.PrepareToEncode True
Encoder.Start
End Sub[/red]
DELPHI代码:(编译通过,运行出错)
[red]unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, OleServer, WMEncoderLib_TLB, WMPREVIEWLib_TLB,
WMDEVICECONTROLLib_TLB;

type
TForm1 = class(TForm)
Button1: TButton;
WMEncoder1: TWMEncoder;
VideoSrc1: TVideoSrc;
WMEncEditDecisionList1: TWMEncEditDecisionList;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
Encoder:IWMEncoder;
SrcGrpColl:IWMEncSourceGroupCollection;
SrcGrp:IWMEncSourceGroup;
SrcVid:IWMEncSource;
SrcAud:IWMEncSource;
ProColl:IWMEncProfileCollection;
Pro :IWMEncProfile;
i,Llength:integer;
Descr:IWMEncDisplayInfo;
Attr:IWMEncAttributes;
File1:IWMEncFile;
begin

Encoder:=CoWMEncoder.Create;
SrcGrpColl:=Encoder.SourceGroupCollection
SrcGrp:=SrcGrpColl.add('LgggG_1');
SrcVid := SrcGrp.AddSource(WMENC_VIDEO);
SrcAud := SrcGrp.AddSource(WMENC_AUDIO);

SrcVid.SetInput('c:/lake.mpg','file',' ');
SrcAud.SetInput ('c:/lake.mpg','file',' ');

ProColl:=Encoder.ProfileCollection
SrcGrp.Set_Profile(ProColl.item(2));
Encoder.EnableAutoArchive:=true;

File1 := Encoder.Get_File_
File1.LocalFileName := 'C:/myOutputFile.wmv';

Encoder.PrepareToEncode(true);
Encoder.Start
showmessage('encode complete!');
end;

end.
[/red]
 
后退
顶部