首页 > 解决方案 > 将 ffmpeg 库与 Qt 框架一起使用会导致错误

问题描述

当我包括:

extern "C" {
#include <libavcodec/avcodec.h>
}

我收到错误消息:

未定义对 QVideoSurfaceFormat::QVideoSurfaceFormat(QSize const&, QVideoFrame::AVPixelFormat, QAbstractVideoBuffer::HandleType) 的引用

没有包含 - 构建成功。

我的猜测包括带来了一些打破 QVideoSurfaceFormat 定义的定义。
有人遇到过类似的问题吗?

标签: c++linuxc++11ffmpegqt4

解决方案


#define __STDC_CONSTANT_MACROS // to fix #include <stdint.h> issue
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}

在阅读了网络中的 stdint.h 和相关主题后,找到了适合我的解决方案:

#define __STDC_CONSTANT_MACROS

推荐阅读