directshow dspack(ver 1.02)关于回放输出的问题!(100分)

  • 主题发起人 主题发起人 coolsoft
  • 开始时间 开始时间
C

coolsoft

Unregistered / Unconfirmed
GUEST, unregistred user!
请教各位关于directshow(采用dspack(ver 1.02)),将采集的视频文件,通过采集卡(stream machine)
芯片组,回放出来(带视频输出)
以下是我的方法:
1.目的:将一个采集到的文件(如001.mpg),通过stream machine 2210 pci care 输出
2.
var sysenum: TDSSysDevEnum;
F_source: IBaseFilter;
//stream machine 2210 pci capture card;
F_filesource:Ibasefilter;//file source(async. video);//文件提供者
// F_Filesource_video:Ibasefilter;//file source(async. video);文件提供者 视频
// F_filesource_audio:Ibasefilter;//file source(async. audio);
文件提供者 音频;
F_BWmpeg2Splitter:Ibasefilter;//broadwan mpeg2 splitter ,splitter audio and video output;
F_MpegAudiodec:ibasefilter;//mpeg audio decode;音频解码;
// F_MpegVideodec:ibasefilter;
// Ligos MPEG Video Decoder (ULead) //
// F_mepgSplitter:Ibasefilter;// Ligos MPEG Splitter (ULead)
F_videorender:Ibasefilter;
//video render filter;
F_overlaymixer2:Ibasefilter;//
//定义PIN,
//all used pins in the stream machine 2210 capture;
Pin_audiorender_in:IPIN;
//stream machine 2210 pci caputre ,audio render(in)
pin_Mpegvideo_in:ipin;
// stream machine 2210 pci caputre ,mpeg video in(in)
// Pin_audioout_out:Ipin;//stream machine 2210 pci capture,capture(output)
pin_video_out:Ipin;
//stream machine 2210 pci caputre ,video out ,(output)

//all pins in the filesource;
Pin_Filesource_out:Ipin;
//file source async. output pin;
//all pins in the broadwan mpeg2 spltter
pin_bwmpeg2sp_in:ipin;
//in
pin_bwmpeg2sp_video:ipin;//out video;
pin_bwmpeg2sp_audio:ipin;//out audio
//all pins in the overlaymixer
Pin_overlaymixer_in:Ipin;// overlay mixer2 input,in
Pin_overlaymixer_out:Ipin;//overlay mixer2 output,out;
//all pins in the Mpeg audio decoder;
pin_xformin_in:Ipin;//mpeg audio decoder xform in
pin_xformout_out:ipin;//mpeg audio decoder xform out;
//all pins in the video render filter;
Pin_videorender_in:Ipin;// video render Input,in;the last pin of the filter chain;
//其它变量定义
hr:hresult;
s_name:pchar;
pc_char:pwidechar;
file_output:IFileSourceFilter;
begin

if not capturegraph.Connected then


CaptureGraph.Connect;
sysenum := TDSSysDevEnum.Create;
sysenum.SelectGUIDCategory(CLSID_VideoInputDeviceCategory);
// select video Capture category
if (sysenum.CountFilters = 0) then

begin

Messagebox(0,'No video capture device found','error',id_ok);
sysenum.Destroy;
CaptureGraph.Disconnect;
Application.Terminate;
end;


F_source := sysenum.GetBaseFilterByIndex(0);
// get the first Filter capture device
// StatusBar.SimpleText := sysenum.Filters[0].FriendlyName;
// get the filter name
CaptureGraph.GraphBuilder.AddFilter(F_source, 'Video Capture');
// Add filter to graph,and named it video capture;
sysenum.Destroy;
//建立file source async filter
// capturegraph.GraphBuilder.AddSourceFilter(pwchar(widestring(s_file)),pwchar(widestring('file sourc (async)')),f_filesource);
F_filesource:=createcomobject(CLSID_filesource2) as ibasefilter;
F_filesource.QueryInterface(IID_IFileSourceFilter, File_output);
// file_output.SetFileName(pwchar(widestring(s_file)),nil);
//建立broadwan mpeg2 splitter
// F_Bwmpeg2Splitter:=createcomobject(CLSID_BWMPEG2Sp) as ibasefilter;
file_output.Load(pwchar(widestring(s_file)),nil);
F_Bwmpeg2Splitter:=createcomobject(CLSID_streammachinesplitter) as ibasefilter;

//建立mpeg audio decoder filter
F_MpegAudiodec:=createcomobject(CLSID_CMpegAudioCodec) as ibasefilter;
//建立overlay mixer2 的filter;
F_overlaymixer2:=createcomobject(CLSID_OverlayMixer2) as ibasefilter;
//建立video render的filter;
F_videorender:=createcomobject(CLSID_VideoRenderer) as ibasefilter;

//加入到graph builder 中

capturegraph.GraphBuilder.AddFilter(f_filesource,'File Source (Async.)');
capturegraph.GraphBuilder.AddFilter(f_BWmpeg2splitter,'stream machine splitter');
capturegraph.GraphBuilder.AddFilter(f_mpegaudiodec,'MPEG Audio Decoder');
capturegraph.GraphBuilder.AddFilter(f_overlaymixer2,'Overlay Mixer2');
capturegraph.GraphBuilder.AddFilter(f_videorender,'Video Renderer');
//得到各个PIN
//all pins in the filesource;
Pin_Filesource_out:=getpin(F_filesource,'output');
//all pins in the overlaymixer
Pin_overlaymixer_in:=getpin(f_overlaymixer2,'input0');// overlay mixer2 input,in
Pin_overlaymixer_out:=getpin(f_overlaymixer2,'output');//overlay mixer2 output,out;
//all pins in the Mpeg audio decoder;
pin_xformin_in:=getpin(F_mpegaudiodec,'xform in');//mpeg audio decoder xform in
pin_xformout_out:=getpin(f_mpegaudiodec,'Xform out');//mpeg audio decoder xform out;
//all pins in the video render filter;
Pin_videorender_in:=getpin(F_videorender,'input');// video render Input,in;the last pin of the filter chain;
//all used pins in the stream machine 2210 capture;
Pin_audiorender_in:=getpin(f_source,'audio render');
//stream machine 2210 pci caputre ,audio render(in)
pin_Mpegvideo_in:=getpin(f_source,'mpeg video in');
// stream machine 2210 pci caputre ,mpeg video in(in)
//stream machine 2210 pci capture,capture(output)
pin_video_out:=getpin(f_source,'video out');
//stream machine 2210 pci caputre ,video out ,(output)
//all pins in the broadwan mpeg2 spltter
pin_bwmpeg2sp_in:=getpin(f_bwmpeg2splitter,'input');
//in
pin_bwmpeg2sp_video:=getpin(f_bwmpeg2splitter,'video');//out video;
pin_bwmpeg2sp_audio:=getpin(f_bwmpeg2splitter,'audio');//out audio

{ hr:= capturegraph.GraphBuilder.Render(pin_filesource_out);
if hr<>s_ok then

begin

application.messagebox(pchar('初始化文件失败!'),pchar('系统提示'),48);
exit;
end;
}
{ hr:= capturegraph.GraphBuilder.Render(pin_videorender_in);
if hr<>s_ok then

begin

application.messagebox(pchar('render videorender failt!'),pchar('系统提示'),48);
exit;
end;
}
//连接各个pin


capturegraph.GraphBuilder.Connect(Pin_filesource_out,Pin_bwmpeg2sp_in);
capturegraph.GraphBuilder.Connect(pin_bwmpeg2sp_video,pin_mpegvideo_in);
capturegraph.graphbuilder.connect(pin_bwmpeg2sp_audio,pin_xformin_in);
capturegraph.graphbuilder.connect(pin_xformout_out,pin_audiorender_in);
capturegraph.graphbuilder.connect(pin_video_out,pin_overlaymixer_in);
capturegraph.graphbuilder.connect(pin_overlaymixer_out,pin_videorender_in);[red]
//下面这句应该是关键,问题可能出在这,希望各位在富翁指教!

capturegraph.CaptureGraphBuilder2.RenderStream(@CLSID_filesource2,@mediatype_stream,f_filesource,nil,F_videorender);
[/red]

CaptureGraph.QueryInterfaces;
// capturegraph.CaptureGraphBuilder2.render
capturegraph.MediaControl.run;
 
后退
顶部