使用ffmpeg 3.3+sdl 2.0 不能直接獲取攝像頭的緣由

本文主要是下面這個連接的補充http://www.javashuo.com/article/p-wsapsfzc-gn.htmlide

avdevice_register_all ();
avformat_network_init ();
av_register_all ();
AVFormatContext	* pFormatCtx = avformat_alloc_context ();
AVInputFormat *ifmt = av_find_input_format ( "dshow" );
av_register_input_format ( ifmt ); // 惟一區別,在我使用的3.3版本中,不加此句會獲取失敗
if (avformat_open_input ( &pFormatCtx, "video=Integrated Camera", ifmt, NULL ) != 0)
{
		printf ( "Couldn't open input stream.\n" );
		return -1;
}

2. main函數進不去的解決辦法: 在此過程當中,碰到了include "SDL.h" 就會進不去main函數的問題,解決辦法是在main函數以前加上#undef main 。發生這種狀況的緣由是由於sdl這個lib中定義了main,而咱們通常都是先聲明頭文件,這樣編譯器在尋找main的過程當中,就會先在sdl中發現main這個關鍵字,最終就致使了每次咱們啓動程序,入口點就變成sdl定義的main函數。函數

歡迎在下方留言探討.net

相關文章
相關標籤/搜索