Introduction of ffmpeg dynamic library into Qt

1. Preliminary preparation

When Qt introduces the ffmpeg dynamic library, you need to prepare the ffmpeg dynamic library and header files.
Insert image description here

2. Open the qt project

Add the following lines of code to the .pro file of the qt project

INCLUDEPATH += $$PWD/thirtLib/ffmpeg4.2/include
win32: LIBS += -L$$PWD/thirtLib/ffmpeg4.2/lib/ -lavcodec -lavdevice -lavfilter -lavformat -lavutil -lpostproc -lswresample -lswscale

Insert image description here

What needs to be noted here is whether it corresponds to 64-bit or 32-bit. Otherwise, an error may be reported.
Copy the dll file in lib here under the generated file execution path. Otherwise the software will crash.

3. After adding

Add header files to the project

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

Use the code after adding

qDebug()<<"version"<<avcodec_version();
qDebug()<<avcodec_configuration();

result:

version 3815012
--disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt

The above information appears, indicating that the ffmpeg library was added successfully.

Library download link: https://download.csdn.net/download/qq_43812868/88151401?spm=1001.2014.3001.5503

Guess you like

Origin blog.csdn.net/qq_43812868/article/details/132068436