请问如何取得采集摄像机视频后的原始数据?

anstern 2009-12-22 11:16:37
我从CameraCapture的例子编译后运行程序,程序从摄像机取得视频后,直接编码和生成ASF文件,代码如下,但我不想这么取得ASF文件,我想直接获取摄像机取得的视频流裸数据(即RGB数据或YUV数据),然后自己编码成H.264码流,该怎么改造程序呢,大家给给思路吧。

//
// Create the capture graph builder and register the filtergraph manager.
//
CHK( m_pCaptureGraphBuilder.CoCreateInstance( CLSID_CaptureGraphBuilder ));
CHK( pFilterGraph.CoCreateInstance( CLSID_FilterGraph ));
CHK( m_pCaptureGraphBuilder->SetFiltergraph( pFilterGraph ));


//
// Create and initialize the video capture filter
//
CHK( m_pVideoCaptureFilter.CoCreateInstance( CLSID_VideoCapture ));
CHK( m_pVideoCaptureFilter.QueryInterface( &pPropertyBag ));

// We are loading the driver CAM1 in the video capture filter.
CHK( GetFirstCameraDriver( wzDeviceName ));
varCamName = wzDeviceName;
if( varCamName.vt != VT_BSTR )
{
ERR( E_OUTOFMEMORY );
}

CHK( PropBag.Write( L"VCapName", &varCamName ));
CHK( pPropertyBag->Load( &PropBag, NULL ));

// Everything succeeded, the video capture filter is added to the filtergraph
CHK( pFilterGraph->AddFilter( m_pVideoCaptureFilter, L"Video Capture Filter Source" ));


//
// Third step: Create the video encoder DMO, load the WMV9 encoder, and
// add it to the graph
//

// Create the video encoder
CHK( pVideoEncoder.CoCreateInstance( CLSID_DMOWrapperFilter ));
CHK( pVideoEncoder.QueryInterface( &pWrapperFilter ));

// Load the WMV9 DMO
CHK( pWrapperFilter->Init( CLSID_CWMV9EncMediaObject, DMOCATEGORY_VIDEO_ENCODER ));

// Everything succeeded, let's add the encoder to the graph
CHK( pFilterGraph->AddFilter( pVideoEncoder, L"WMV9 DMO Encoder" ));

//
// Create the ASF multiplexer and add it to the graph
//
CHK( m_pCaptureGraphBuilder->SetOutputFileName( &MEDIASUBTYPE_Asf, L"\\video1.asf", &pASFMultiplexer, &pFileSinkFilter ));

//
// Connect the video capture filter, the encoder and the multiplexer together
//
CHK( m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pVideoCaptureFilter, pVideoEncoder, pASFMultiplexer ));
...全文
516 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
rageliu 2009-12-31
  • 打赏
  • 举报
回复
写个render也可以
SoftSoftSoft2008 2009-12-22
  • 打赏
  • 举报
回复
你参考一下 DX 的例子 Amcap 这个工程即可。
yinfuyong 2009-12-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 mjh1021 的回复:]
你在链路中加入了grabber filter 格式设为你想要的YUV或RGB,就可以从这个grabber filter中取原始数据出来。
[/Quote]
=================================================================
同意楼上的,在中间加个filter,但也不一定非用grabber filter,可以添加一个filter来设置想要的格式
lyg1761983 2009-12-22
  • 打赏
  • 举报
回复
可以看陆其明的《DirectShow务实精选》中的视频聊天,AVChat例子程序。用其中的FilterNetSender就可以了。

-------------------------------------
我现在的问题是,取到Sample了,但是不知该如何处理了。
mjh1021 2009-12-22
  • 打赏
  • 举报
回复
你在链路中加入了grabber filter 格式设为你想要的YUV或RGB,就可以从这个grabber filter中取原始数据出来。

2,543

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧