DSPACK 用指定的解码器播放视频
//用指定的解码器播放视频(未完待续)
//哪天心情好的时候,把代码全写出来
// 贴了几天了,还是没有几个人看,感叹大富翁的人大部份都是衣来伸手,饭来张口的主哈(只知道拿来用,不会去分析代码哈)。不会要我把每一句的意思都要用中文说明吧
//加入到DSutil
CLSID_MPEG2Splitter: TGUID = '{AFB6C280-2C41-11D3-8A60-0000F81E0E4A}';
CLSID_ElecardMpeg2Splitter: TGUID = '{731B8592-4001-46D4-B1A5-33EC792B4501}';
CLSID_LigosMPEGVideoDecoder: TGUID = '{CB51EFC2-40D6-11D3-B265-00A0C9A3A56F}';
CLSID_CyberLinkVideoSPDecoder: TGUID='{9BC1B781-85E3-11D2-98D0-0080C84E9C39}';
//用GraphEdit查看FFSHOW编码的GUID,然后写到这里
//修改 DSPACK的Renderfile (用下面的替换)
function TFilterGraph.RenderFile(FileName: WideString): HRESULT;
var
pSplit, pVidDecoder, pSrc: IBaseFilter;
pfsf: IFileSourceFilter;
pSrcPin: IPin;
begin
result := S_FALSE;
if assigned(FFilterGraph) then
begin
ControlEvents(ceFileRendering);
// result := CheckDSError(FFilterGraph.RenderFile(PWideChar(FileName), nil));
//指定视频解码
// 创建File Source (Async) Filter实例并加入到Filter Graph中.
CoCreateInstance(CLSID_AsyncReader, nil,CLSCTX_INPROC,IID_IBaseFilter, pSrc);
FFilterGraph.AddFilter(pSrc, 'File Source Filter');
// 为File Source Filter指定播放文件名
pSrc.QueryInterface (IID_IFileSourceFilter, pfsf);
pfsf.Load(PWideChar(FileName), nil);
pfsf := nil;
// 创建Demultiplexer Filter实例并加入到Filter Graph中.
CoCreateInstance(CLSID_ElecardMpeg2Splitter{CLSID_MPEG2Splitter}, nil ,CLSCTX_INPROC, IID_IBaseFilter, pSplit);
FFilterGraph.AddFilter(pSplit, 'Elecard MPEG2 Demultiplexer');//MPEG-2 Demultiplexer'); //Elecard MPEG2 Demultiplexer
pSplit := nil;
// 创建Video Decoder Filter实例并加入到Filter Graph中.
CoCreateInstance(CLSID_CyberLinkVideoSPDecoder{CLSID_LigosMPEGVideoDecoder}, nil,CLSCTX_INPROC, IID_IBaseFilter, pVidDecoder);
FFilterGraph.AddFilter(pVidDecoder, 'CyberLink Video/SP Decoder');//'Ligos MPEG Video Decoder');
pVidDecoder := nil;
pSrcPin := GetOutPin (pSrc, 0);
// 获取Source Filter的Source Pin指针
FFilterGraph.Render(pSrcPin); // 在这个Pin上Render已建立完整的Graph
pSrc := nil;
pSrcPin := nil;
if Succeeded(result) then
begin
UpdateGraph;
ControlEvents(ceFileRendered);
end;
end;
end;