下载源码
设置环境参数
将下载好的ffmpeg库文件解压添加到源码文件夹下,设置.qmake.conf 文件配置
INCLUDEPATH += $$PWD/ffmpeg/include
LIBS += -L$$PWD/ffmpeg/lib
找不到avutil库
继续在.qmake.conf中设置要使用的配置添加下面语句
CONFIG += no_config_tests
CONFIG+=config_avutil config_avformat config_avcodec config_swscale config_swresample
打开QT Creator加载QtAV.pro进行编译
其它编译错误处理
error LNK2019: 无法解析的外部符号 "enum QtAV::VideoFormat::PixelFormat __cdecl QtAV::pixelFormatFromFourcc(int)"
在libQtAV.pro中第280+行的win32:!winrt结构中增加CONFIG *= d3dva语句
无法找到avresamle
注释掉libQtAV.pro中137行开始的config_avresample结构体中所有内容。
未定义的 class“QPainterPath”
在src/QtAV/FilterContext.h中引用#include <QPainterPath>头文件
qml\SGVideoNode.cpp:57: error: C2504: “QSGMaterial”: 未定义基类
加入#include <QSGMaterial>
src\subtitle\SubtitleProcessorFFmpeg.cpp:252: error: C2065: “FF_INPUT_BUFFER_PADDING_SIZE”: 未声明的标识符
修改FF_INPUT_BUFFER_PADDING_SIZE为AV_INPUT_BUFFER_PADDING_SIZE。
src\AVMuxer.cpp:125: error: C2065: “CODEC_FLAG_GLOBAL_HEADER”: 未声明的标识符
修改CODEC_FLAG_GLOBAL_HEADER为AV_CODEC_FLAG_GLOBAL_HEADER
src\codec\audio\AudioEncoderFFmpeg.cpp:156: error: C2065: “FF_MIN_BUFFER_SIZE”: 未声明的标识符 和 src\codec\video\VideoEncoderFFmpeg.cpp:248: error: C2065: “FF_MIN_BUFFER_SIZE”: 未声明的标识符
修改FF_MIN_BUFFER_SIZE为AV_INPUT_BUFFER_MIN_SIZE
简易安装(安装至Qt程序中)
编译成功后在编译目录下找到sdk_install.bat文件运行即可
不安装直接使用库
如不使用qml也可直接使用库程序,编译成功后分别在debug和release编译目录下找到lib_win_x86文件夹,将里面QtAVd*.lib、QtAVd*.dll和QtAVWidgets*.lib、QtAVWidgets*.dll复制出来作为库文件。Lib文件可以改名,dll文件不可改名,有d结尾的为debug文件。头文件复制源码中的src/QtAV文件夹和widgets/QtAVWidgets文件夹。整理后的目录结构如下所示(除Qt*以外的dll为ffmpeg支持文件)
+---QtAV
| +---bin
| | avcodec-58.dll
| | avdevice-58.dll
| | avfilter-7.dll
| | avformat-58.dll
| | avutil-56.dll
| | postproc-55.dll
| | QtAV1.dll
| | QtAVd1.dll
| | QtAVWidgets1.dll
| | QtAVWidgetsd1.dll
| | swresample-3.dll
| | swscale-5.dll
| |
| +---include
| | +---QtAV
| | | AudioDecoder.h
| | | AudioEncoder.h
| | | AudioFormat.h
| | | AudioFrame.h
| | | AudioOutput.h
| | | AudioResampler.h
| | | AVClock.h
| | | AVDecoder.h
| | | AVDemuxer.h
| | | AVEncoder.h
| | | AVError.h
| | | AVMuxer.h
| | | AVOutput.h
| | | AVPlayer.h
| | | AVTranscoder.h
| | | ConvolutionShader.h
| | | dptr.h
| | | EncodeFilter.h
| | | FactoryDefine.h
| | | Filter.h
| | | FilterContext.h
| | | Frame.h
| | | FrameReader.h
| | | Geometry.h
| | | GeometryRenderer.h
| | | GLSLFilter.h
| | | LibAVFilter.h
| | | MediaIO.h
| | | OpenGLRendererBase.h
| | | OpenGLTypes.h
| | | OpenGLVideo.h
| | | OpenGLWindowRenderer.h
| | | Packet.h
| | | QPainterRenderer.h
| | | QtAV
| | | QtAV.h
| | | QtAV_Global.h
| | | Statistics.h
| | | SubImage.h
| | | Subtitle.h
| | | SubtitleFilter.h
| | | SurfaceInterop.h
| | | version.h
| | | VideoCapture.h
| | | VideoDecoder.h
| | | VideoEncoder.h
| | | VideoFormat.h
| | | VideoFrame.h
| | | VideoFrameExtractor.h
| | | VideoOutput.h
| | | VideoRenderer.h
| | | VideoShader.h
| | | VideoShaderObject.h
| | |
| | \---QtAVWidgets
| | global.h
| | GLWidgetRenderer.h
| | GLWidgetRenderer2.h
| | GraphicsItemRenderer.h
| | OpenGLWidgetRenderer.h
| | QOpenGLWidget.h
| | QtAVWidgets
| | QtAVWidgets.h
| | version.h
| | VideoPreviewWidget.h
| | WidgetRenderer.h
| |
| \---lib
| Qt5AV.lib
| Qt5AVd.lib
| Qt5AVWidgets.lib
| Qt5AVWidgetsd.lib
\--------------------------------------------
https://github.com/wang-bin/QtAV
3万+



被折叠的 条评论
为什么被折叠?



