This article focuses on the integration of FFmpeg into Qt projects

FFmpeg

The installation

In a MacOS environment, install FFmpeg directly using Homebrew. If Homebrew is too slow to download, you can use cUST images, as described in the article using CUST images for Homebrews.

brew install ffmpeg
Copy the code

If you can view the FFmpeg version on the CLI, FFmpeg is successfully installed.

ffmpeg -version
Copy the code

The directory structure

Brew Install installs the software in the /usr/local/cellar directory. You can use the following command to open the FFmpeg installation directory:

CD/usr/local/Cellar/ffmpeg 4.3.2 ls - alCopy the code

  • Bin: compiled executable programs such as FFmpeg and ffplay can be used directly from the command line, for example:
    • Ffplay XX. mp4: Plays a video
    • Ffmpeg-version: Displays the FFMPEG version
  • Include: header files that need to be included during development
  • Lib: library file used for linking

Qt

The installation

Install Qt via brew Install and end up in /usr/local/cellar/Qt.

brew install qt
Copy the code

Install Qt Creator via brew install –cask, which is eventually installed in /usr/local/caskroom/qt-Creator.

brew install --cask qt-creator
Copy the code

integration

Add the following configuration to Qt’s.pro file, and the integration will be successful if the FFmpeg header file is imported in the project. Note: Since FFmpeg is written entirely in C, extern “C”{} is required to introduce header files.

INCLUDEPATH + = # set header file path - I/usr/local/Cellar/ffmpeg 4.3.2 / include # Settings library file path LIBS + = L/usr/local/Cellar/ffmpeg 4.3.2 / lib  \ -lavcodec \ -lavdevice \ -lavfilter \ -lavformat \ -lavutil \ -lpostproc \ -lswscale \ -lswresample \ -lavresampleCopy the code