在QT中使用FFmpeg库的部分报错问题

win32: LIBS += -L$$PWD/../ffmpeg-win32-dev/lib/ -lavutil
win32: LIBS += -L$$PWD/../ffmpeg-win32-dev/lib/ -lavformat
win32: LIBS += -L$$PWD/../ffmpeg-win32-dev/lib/ -lswresample
win32: LIBS += -L$$PWD/../ffmpeg-win32-dev/lib/ -lswscale
INCLUDEPATH += $$PWD/../ffmpeg-win32-dev/include
DEPENDPATH += $$PWD/../ffmpeg-win32-dev/include
#include <libavutil/channel_layout.h> //用户音频声道布局操作

#include <libavutil/opt.h> //设置操作选项操作
#include <libavutil/mathematics.h> //用于数学相关操作
#include <libavutil/timestamp.h> //用于时间戳操作
#include <libavformat/avformat.h> //用于封装与解封装操作
#include <libswscale/swscale.h> //用于缩放、转换颜色格式操作
#include <libswresample/swresample.h> //用于进行音频采样率操作

使用遇到错误:D:ffmpegdevincludelibavutilcommon.h:210: error: ‘UINT64_C’ was not declared in this scope 

if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (int32_t)((a>>63) ^ 0x7FFFFFFF);

解决方法:

1 在common.h文件中加入
2 #ifndef INT64_C
3 #define INT64_C(c) (c ## LL)
4 #define UINT64_C(c) (c ## ULL)
5 #endif

使用遇到错误D:ffmpegdevincludelibavutilcommon.h:32: error: #error missing -D__STDC_CONSTANT_MACROS / #define __STDC_CONSTANT_MACROS
#error missing -D__STDC_CONSTANT_MACROS / #define __STDC_CONSTANT_MACROS
解决办法:

1 记住要加到error missing -D__STDC_CONSTANT_MACROS 的前面不然还是找不到
2 #if defined __cplusplus
3 #define __STDC_CONSTANT_MACROS
4 #endif

注:以上类似#error missing -D__STDC_CONSTANT_MACROS 的错误都可以这样处理。

建议都在common.h文件里声明,如下

 1 /////新增////////////
 2 #ifndef INT64_C
 3 #define INT64_C(c) (c ## LL)
 4 #define UINT64_C(c) (c ## ULL)
 5 #endif
 6 
 7 #if defined __cplusplus
 8 #define __STDC_CONSTANT_MACROS  //common.h中的错误
 9 #define __STDC_FORMAT_MACROS    //timestamp.h中的错误
10 #endif
11 
12 /////////////////////

参考:https://blog.csdn.net/qq_36088602/article/details/77885023

undefined reference to `av_register_all' 问题解决

解决方法:

#include <libavcodec/avcodec.h>

#include <libavformat/avformat.h>

引入头文件因为实在cpp的环境下引入的,需要

extern "C"

{

#include <libavcodec/avcodec.h>

#include <libavformat/avformat.h>

}

切记 exterm后面一定要跟{}。

这样写

extern "C"

#include <libavcodec/avcodec.h>

#include <libavformat/avformat.h>

是没有用的 这种是错误的。一定要带{},否则还是回报同样的错误。
参考:https://blog.csdn.net/qq_18144521/article/details/79608355

原文地址:https://www.cnblogs.com/liushui-sky/p/11691399.html