有没有什么办法可以从DirectShow中使用Libav在Windows平台上捕获尽可能多的相机类型的帧?我需要在不使用DirectShow过滤器的情况下捕获相机输出,并且我希望我的应用程序能够使用许多相机设备类型。如何使用Libav在Windows上捕捉摄像头设备?
我已经在Internet上搜索了libav的这个功能,发现它可以通过使用特殊输入格式“vfwcap”的libav完成。类似的事情(做不知道代码的正确性 - 我写的我自己):
AVFormatParameters formatParams = NULL;
AVInputFormat* pInfmt = NULL;
pInFormatCtx* pInFormatCtx = NULL;
av_register_all();
//formatParams.device = NULL; //this was probably deprecated and then removed
formatParams.channel = 0;
formatParams.standard = "ntsc"; //deprecated too but still available
formatParams.width = 640;
formatParams.height = 480;
formatParams.time_base.num = 1000;
formatParams.time_base.den = 30000; //so we want 30000/1000 = 30 frames per second
formatParams.prealloced_context = 0;
pInfmt = av_find_input_format("vfwcap");
if(!pInfmt)
{
fprintf(stderr,"Unknown input format\n");
return -1;
}
// Open video file (formatParams can be NULL for autodetecting probably)
if (av_open_input_file(&pInFormatCtx, 0, pInfmt, 0, formatParams) < 0)
return -1; // Couldn't open device
/* Same as video4linux code*/
那么另一个问题是:有多少设备通过Libav的支持?我发现在windows上使用libav捕获摄像头输出的所有建议都是为了这个目的使用DirectShow,因为libav支持的设备太少。也许情况已经改变了,它确实支持足够的设备在生产应用中使用它?
如果这是不可能的......那么我希望我的问题不会是无用的,这由不同来源组成的一段代码将帮助对这个主题感兴趣的人''因为真的太少有关它的信息整个互联网。
对于那些感兴趣的人来说,有一个名为“libvidcap”的分离跨平台库用于处理视频捕获目的。你可以在[sourceforge]上看到它(http://sourceforge.net/projects/libvidcap/)。 –