有沒有什麼辦法可以從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/)。 –