1 Introduction to FFmpeg
FFmpeg: FFmpeg is a set of open source computer programs that can be used to record, convert digital audio and video, and convert them into streams. Use LGPL or GPL license. It provides a complete solution for recording, converting and streaming audio and video. The name of the project comes from the MPEG video coding standard, with the "FF" in front of it standing for "Fast Forward". ——Baidu Encyclopedia
2 FFmpeg download and installation
2.1 Download
FFmpeg official website download page: https://ffmpeg.org/download.html .
If you have special requirements for use or platform, you can download the source code and compile it yourself.
If it is just for normal use, the official website has provided some compiled libraries that can be used directly. Point the mouse to the Windows icon on the above page, and then select the link to enter. I usually enter Windows builds by BtbN. After entering, you can see many versions of libraries . The latest version is 6.0. I chose to download ffmpeg-master-latest-win64-gpl-shared.zip . You can also choose to download earlier versions of the library.
2.2 Installation
This package contains the bin, include, and lib files of the 64-bit version of FFmpeg, which can be used for 64-bit application development. After downloading, unzip it to a suitable location. For example, I unzipped it directly to F:\.
For ease of use, add the decompressed bin directory to the system's Path variable.
3 FFmpeg compiler development environment settings
3.1 VS series compiler
If you use Microsoft series compilers such as VS2015, VS2017, etc., in the property page of the project to be added to FFmpeg:
first, set the C/C++ General-Additional Include Directory, and add the include directory of FFmpeg.
Second, set the linker-General -Additional library directory, add the FFmpeg lib directory.
Third, add the FFmpeg lib to be used in Linker-Input-Additional Dependencies. This generally depends on what functions you need to use. If you are not sure, you can at least Add the following:
avcodec.lib
avformat.lib
avutil.lib
swscale.lib
avfilter.lib
avdevice.lib
postproc.lib
swresample.lib
3.2 Qt series compilers
If you are using the qt compiler, add it directly to the pro file of the project. Similarly, which lib should be added depends on which functions are used. The following general functions are included:
INCLUDEPATH += F:/ffmpeg-master-latest-win64-gpl-shared/include
LIBS += F:/ffmpeg-master-latest-win64-gpl-shared/lib/avcodec.lib
LIBS += F:/ffmpeg-master-latest-win64-gpl-shared/lib/avformat.lib
LIBS += F:/ffmpeg-master-latest-win64-gpl-shared/lib/avutil.lib
LIBS += F:/ffmpeg-master-latest-win64-gpl-shared/lib/swscale.lib
LIBS += F:/ffmpeg-master-latest-win64-gpl-shared/lib/avfilter.lib
LIBS += F:/ffmpeg-master-latest-win64-gpl-shared/lib/avdevice.lib
LIBS += F:/ffmpeg-master-latest-win64-gpl-shared/lib/postproc.lib
LIBS += F:/ffmpeg-master-latest-win64-gpl-shared/lib/swresample.lib
4 include in code
When the code includes the corresponding FFmpeg header file, you should pay attention to one thing. Since most of the code is currently written in C++, and the FFmpeg library is written in C, the CPP file must be included using a C-compatible method:
#ifdef __cplusplus
extern "C"
{
#endif
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>
#include <libavutil/pixfmt.h>
#ifdef __cplusplus
}
#endif
Otherwise, the compilation will pass, but an error will occur during linking. Even though the FFmpeg lib library has been added, the link error of "unresolvable external symbol" will still be prompted.
After the configuration is completed, you can try to use FFmpeg for video decoding. Please refer to the next article FFmepg video decoding .