首先要配置好FFmpeg和opencv环境,ffpmeg可以直接读取tcp视频流数据,只需将设置好ip地址和端口即可直接打开这个数据流。然后设置好解码器,
//配置静态库,也可直接添加到附加依赖项中
#pragma comment(lib, "legacy_stdio_definitions.lib")
#pragma comment(lib, "avcodec.lib")
#pragma comment(lib, "avformat.lib")
#pragma comment(lib, "avdevice.lib")
#pragma comment(lib, "avfilter.lib")
#pragma comment(lib, "avutil.lib")
#pragma comment(lib, "postproc.lib")
#pragma comment(lib, "swresample.lib")
#pragma comment(lib, "swscale.lib")
#pragma comment(lib, "ws2_32.lib")
int main(int argc, char *argv[]) {
AVFormatContext *pFormatCtx;
int i, videoindex;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
// Init
avcodec_register_all();
//avdevice_register_all();
avformat