preface

There are many examples of FFmpeg integration on iOS on the web, many of which are written in detail. This article is summed up by the author referring to several online examples of iOS integration and his own practice. Hoping to help those in need and step on fewer holes.

1. Download and install FFmpeg

Brew install ffmpeg // Brew info ffmpeg // Check the installed versionCopy the code

2. Download the script and use the script to convert the downloaded FFmpeg into a usable iOS package

Script address: github.com/kewlbear/FF… Find ffmpeg.sh in your downloaded local script

Modify the ffmpeg.sh script file based on your requirements

  • Set the FFmpeg version

    FF_VERSION = “4.3.2”

  • Set the schema to be supported

    ARCHS=”arm64 armv7 x86_64 i386″

  • Set up the required FFmpeg function configuration

    Disable some unnecessary features, CONFIGURE_FLAGS=”–enable-cross-compile –disable-debug –disable-programs –disable-doc –enable-pic” CONFIGURE_FLAGS=”–enable-cross-compile –disable-debug –disable-programs –disable-doc –enable-pic” –disable-cross-compile disables cross-compile –enable-cross-compile supports cross-compile

  • Go to the script folder and execute the script

    ./build-ffmpeg.sh

The execution result

3. Import FFMPEG-ios into the project

  • Add FFMPEG-ios to the project

  • Adding a dependency library

libz.tbd

libbz2.tbd

libiconv.tbd

AudioToolbox.framework

CoreMedia.framework

VideoToolbox.framework

  • Sets the header file path to search for

$(PROJECT_DIR)/iOS_FFmpeg_Demo/ffmpeg-universal/include

  • C, CMDutils.h /. C, FFMpeG_opt. c, FFMPEg_filter. c, ffmpeg_hw.c and other files are added to FFmPEG-ios

4. Common errors are reported during compilation

  • ‘config.h’ file not found a header file is missing, go to the scratch folder and drag it down to the project;

  • 'libavcodec/avcodec.h' file not found 'libavcodec/avcodec.h' file not found 'libavcodec/avcodec.h' file not found 'libavcodec/avcodec.h' file not found 'libavcodec/avcodec.h' file not found

  • FFmpeg also has a main function. If the main function is not renamed, it will conflict with the error.

  • Open the ffmpeg.c file, find the main function, and change it to ffmpeg_main.

  • And declared in ffmpeg.h.