在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:\ffmpeg\dev\include\libavutil\common.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:\ffmpeg\dev\include\libavutil\common.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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM