1. mac 上安装 ffmpeg
,并打印版本号
brew install ffmpeg
ffmpeg -version
2. mac 上安装 Qt
和 Qt Creator
brew install qt
brew install --cask qt-creator
3. 给 Qt Creator
配置 qt
-
① 打开
Qt Creator
→ 偏好设置 → Kits →Qt Versions
→添加
→ 找到 Qt 所在目录/usr/local/Cellar/qt
→ 选择bin
目录下的qmake
-
② 打开
Qt Creator
→ 偏好设置 → Kits → 找到Qt version
选择我们刚刚配置的Qt
4. 集成 FFmpeg
到 Qt
项目中
# 设置头文件路径
INCLUDEPATH += /usr/local/Cellar/ffmpeg/4.3.2/include
# 设置库文件路径
LIBS += -L /usr/local/Cellar/ffmpeg/4.3.2/lib \
-lavcodec \
-lavdevice \
-lavfilter \
-lavformat \
-lavutil \
-lpostproc \
-lswscale \
-lswresample \
-lavresample
- 打印版本号
#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
extern "C" {
#include <libavcodec/avcodec.h>
}
int main(int argc, char *argv[])
{
// 打印版本号
qDebug() << av_version_info();
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
5.动态库和静态库有什么区别?
- 静态库:一般是 .a 文件,在链接的时候和我们编写的代码合在一起,最终生成一个可执行文件
- 动态库:一般是 .dyld 文件,并不会合并到最终可执行文件中,只保留接口,而是运行可执行文件的时候
载入动态库
6. .h .dll .dll.a
中文件有什么区别?
.h
是头文件方法声明文件.dll
是方法具体实现文件.dll.a
文件会和我们源代码编译生成可执行文件,并告诉可执行文件 .dll 中方法的入口和位置
信息
7. 为什么 C++ 导入头文件时,有些头文件没有 .h
有些头文件有 .h
?
.h
只是个扩展名,如果乐意也可以写成.abc
,C++ 中很多官方系统库都是没有包含.h
的- 另外如果使用自己的库一般用
引号
#include "mycode.h"
- 如果使用系统的库一般使用
尖括号
#include <QDebug>
8. MainWindow w1;
和 MainWindow *w2 = new MainWindow;
有异同?
-
同: 都创建出了
MainWindow
实例 -
异: ① w1 存储在栈空间中;w2 存储在堆空间中 ② w1 调用其方法用
点语法
;w2 调用其方法用->语法
③ w1 是对象;w2 是引用