我写一程序,要自已获得摄像头的图像,再一幅幅播出去,之所以要这样子做是因为要对获得的图像做些处理再形成视频。搜索网上的一些源码,程序基本能实现,但有一问题,它总要生成一个avi文件,这是我不需要的,而且占硬盘,有什么方法可以去掉。下面是部分代码。请高人指点,谢谢。
解决方案 »
- TSQLConnection的问题
- Test
- 请问如何实现人家安装光盘中的“浏览”功能,点击“浏览”,显示光盘下的所有文件
- 如何保存动态自定义的东西?
- 我得到FontStyle是數字類型,如何把數字轉換成fsBold,fsItalic的形式。
- DELPHI和哪个数据库连接的更好,更稳定一些!!!!
- 求助!!!d7中ttcpserver的用法
- 如何隐藏本程序的进程?
- {88888888-8888-8888-8888-888888888888}象这样是怎么加密的?怎样解密?难道没人懂吗?
- 关于winsock接受数据的问题。(我收不到数据)
- Delphi还是很有前途的
- EmbeddedWB的安装方法,适用于Delphi2010和DelphiXe
var
multiplexer: IBaseFilter;
Writer: IFileSinkFilter;
PinList: TPinList;
i: integer;
begin // Activate the filter graph, at this stage the source filters are added to the graph
CaptureGraph.Active := true; // configure output Audio media type + source
if AudioSourceFilter.FilterGraph <> nil then
begin
PinList := TPinList.Create(AudioSourceFilter as IBaseFilter);
i := 0;
while i < PinList.Count do
if PinList.PinInfo[i].dir = PINDIR_OUTPUT then
begin
if AudioFormats.ItemIndex <> -1 then
with (PinList.Items[i] as IAMStreamConfig) do
SetFormat(AudioMediaTypes.Items[AudioFormats.ItemIndex].AMMediaType^);
PinList.Delete(i);
end else inc(i);
if InputLines.ItemIndex <> -1 then
with (PinList.Items[InputLines.ItemIndex] as IAMAudioInputMixer) do
put_Enable(true);
PinList.Free;
end; // configure output Video media type
if VideoSourceFilter.FilterGraph <> nil then
begin
PinList := TPinList.Create(VideoSourceFilter as IBaseFilter);
if VideoFormats.ItemIndex <> -1 then
with (PinList.First as IAMStreamConfig) do
SetFormat(VideoMediaTypes.Items[VideoFormats.ItemIndex].AMMediaType^);
PinList.Free;
end;
// now render streams
with CaptureGraph as IcaptureGraphBuilder2 do
begin
// set the output filename
SetOutputFileName(MEDIASUBTYPE_Avi, PWideChar(CapFile), multiplexer, Writer); // Connect Video preview (VideoWindow)
if VideoSourceFilter.BaseFilter.DataLength > 0 then
//RenderStream(@PIN_CATEGORY_PREVIEW, nil, VideoSourceFilter as IBaseFilter,
// nil , VideoWindow as IBaseFilter); // Connect Video capture streams
if VideoSourceFilter.FilterGraph <> nil then
RenderStream(@PIN_CATEGORY_CAPTURE, nil, VideoSourceFilter as IBaseFilter,
samplegrabber1 as IBaseFilter, multiplexer as IBaseFilter); // Connect Audio capture streams
if AudioSourceFilter.FilterGraph <> nil then
begin RenderStream(nil, nil, AudioSourceFilter as IBaseFilter,
nil, multiplexer as IBaseFilter);
end;
end;
CaptureGraph.Play;
StopButton.Enabled := true;
StartButton.Enabled := false;
AudioFormats.Enabled := false;
AudioCapFilters.Enabled := false;
VideoFormats.Enabled := false;
VideoCapFilters.Enabled := false;
//Timer.Enabled := true;
end;
============================================================
然后用一循环,通过 samplegrabber1.GetBitmap(bitmap);来获得每帧图片