B
bushi
Unregistered / Unconfirmed
GUEST, unregistred user!
有一个视频压缩的问题。我用Windows media encoder sdk做在DELPHI 5.0下做视频压缩和广播,不知道怎么回事,生成可执行文件后,运行不过去。我用的是Media Encoder 9.
具体的做法是:在DELPHI的Import type libarary中导入Windows media encoder(version 1.0),代码如下。做了好长时间都没有办法,万望能够指点一下,不胜感谢。
每次都是运行到下面的 黑体,即开始压缩时候 在调试环境下 CPU 就报77FA018D ret,然后就编不过去了,我想是可能把AUTOMATION没有激活吧。但是在VB或者VC下又没有什么问题,难道是DELPHI编译器的问题或者是我导入错误?
有没有高手啊,快点出手哦!
unit MediaEncoder;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
OleServer, WMEncoderLib_TLB, StdCtrls, WMPREVIEWLib_TLB;
type
TForm1 = class(TForm)
Button1: TButton;
WMEncPrepreview1: TWMEncPrepreview;
text1: TEdit;
text2: TEdit;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Encoder : WMEncoder;
DVColl_Preview : IWMEncDataViewCollection;
DVColl_Postview : IWMEncDataViewCollection ;
PreView : WMEncDataView ;
PostView : WMEncDataView;
lPreviewStream : integer ;
lPostviewStream : integer;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
SrcGrpColl:IWMEncSourceGroupCollection;
SrcGrp:IWMEncSourceGroup;
SrcVid:IWMEncSource;
SrcAud:IWMEncSource;
ProColl:IWMEncProfileCollection;
Pro :IWMEncProfile;
i,Llength:integer;
Descr:IWMEncDisplayInfo;
Attr:IWMEncAttributes;
File1:IWMEncFile;
FileName:widestring;
begin
Encoder :=CoWMEncoder.Create ;
SrcGrpColl:=Encoder.SourceGroupCollection ;
SrcGrp:=SrcGrpColl.add('LgggG_1');
SrcVid := SrcGrp.AddSource(WMENC_VIDEO);
SrcAud := SrcGrp.AddSource(WMENC_AUDIO);
//换成文件也可以
//SrcVid.SetInput('File://c:/MyFile.mpg',' ',' ');
//SrcAud.SetInput('File://c:/myfle.mpg',' ',' ');
SrcVid.SetInput('DEVICE://o100vc.dll - Osprey Capture Card 1',' ',' ');
SrcAud.SetInput('DEVICE://Default_Audio_Device',' ',' ');
ProColl:=Encoder.ProfileCollection ;
SrcGrp.Set_Profile(ProColl.item(2));
{Llength:=ProColl.Count ;
for i:=0 to Llength-1do
begin
pro:=ProColl.Item(i);
listbox1.Items.Add(pro.name);
If Pro.Name = 'Windows Media Video 8 for Local Area Network (384 Kbps)' then
SrcGrp.Set_Profile(Pro);
end;
}
File1 := Encoder.Get_File_ ;
File1.LocalFileName := 'C:/myOutputFile.wmv';
Encoder.PrepareToEncode(true);//在这里就玩完了
//SrcGrp.PrepareToEncode(true);
Encoder.Start ;
showmessage('encode complete!');
end;
end.
具体的做法是:在DELPHI的Import type libarary中导入Windows media encoder(version 1.0),代码如下。做了好长时间都没有办法,万望能够指点一下,不胜感谢。
每次都是运行到下面的 黑体,即开始压缩时候 在调试环境下 CPU 就报77FA018D ret,然后就编不过去了,我想是可能把AUTOMATION没有激活吧。但是在VB或者VC下又没有什么问题,难道是DELPHI编译器的问题或者是我导入错误?
有没有高手啊,快点出手哦!
unit MediaEncoder;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
OleServer, WMEncoderLib_TLB, StdCtrls, WMPREVIEWLib_TLB;
type
TForm1 = class(TForm)
Button1: TButton;
WMEncPrepreview1: TWMEncPrepreview;
text1: TEdit;
text2: TEdit;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Encoder : WMEncoder;
DVColl_Preview : IWMEncDataViewCollection;
DVColl_Postview : IWMEncDataViewCollection ;
PreView : WMEncDataView ;
PostView : WMEncDataView;
lPreviewStream : integer ;
lPostviewStream : integer;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
SrcGrpColl:IWMEncSourceGroupCollection;
SrcGrp:IWMEncSourceGroup;
SrcVid:IWMEncSource;
SrcAud:IWMEncSource;
ProColl:IWMEncProfileCollection;
Pro :IWMEncProfile;
i,Llength:integer;
Descr:IWMEncDisplayInfo;
Attr:IWMEncAttributes;
File1:IWMEncFile;
FileName:widestring;
begin
Encoder :=CoWMEncoder.Create ;
SrcGrpColl:=Encoder.SourceGroupCollection ;
SrcGrp:=SrcGrpColl.add('LgggG_1');
SrcVid := SrcGrp.AddSource(WMENC_VIDEO);
SrcAud := SrcGrp.AddSource(WMENC_AUDIO);
//换成文件也可以
//SrcVid.SetInput('File://c:/MyFile.mpg',' ',' ');
//SrcAud.SetInput('File://c:/myfle.mpg',' ',' ');
SrcVid.SetInput('DEVICE://o100vc.dll - Osprey Capture Card 1',' ',' ');
SrcAud.SetInput('DEVICE://Default_Audio_Device',' ',' ');
ProColl:=Encoder.ProfileCollection ;
SrcGrp.Set_Profile(ProColl.item(2));
{Llength:=ProColl.Count ;
for i:=0 to Llength-1do
begin
pro:=ProColl.Item(i);
listbox1.Items.Add(pro.name);
If Pro.Name = 'Windows Media Video 8 for Local Area Network (384 Kbps)' then
SrcGrp.Set_Profile(Pro);
end;
}
File1 := Encoder.Get_File_ ;
File1.LocalFileName := 'C:/myOutputFile.wmv';
Encoder.PrepareToEncode(true);//在这里就玩完了
//SrcGrp.PrepareToEncode(true);
Encoder.Start ;
showmessage('encode complete!');
end;
end.