使用ffmpeg 3.3+sdl 2.0 不能直接获取摄像头的原因
时间: 2018-09-02来源:OSCHINA
前景提要
「深度学习福利」大神带你进阶工程师,立即查看>>>
本文主要是下面这个链接的补充 https://blog.csdn.net/leixiaohua1020/article/details/39702113 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函数。
欢迎在下方留言探讨

科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行