1, FFMPEG installation:

  • The brew installation
Brew search ffmpeg brew install ffmpeg // install ffmepgCopy the code
  • Source code (recommended)

Ffmpeg.org/download.ht…

/ / 1. Download ffmpeg package git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg / / 2. /configure --prefix=/usr/local/ ffmpeg-enable-debug =/usr/local/ffmpeg $make -j 4 //-j specifies that multiple cpus are running concurrently. $make install //Copy the code

We can use this command to query the function of the corresponding statement:

./configure --help
Copy the code

Setting environment variables:

export PATH=/usr/local/ffmpeg/bin:$PATH
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/ffmpeg/lib/pkgconfig
Copy the code

2. Problems encountered in creating SWIFT project: After creating a SWIFT project and introducing the dynamic library, the compilation succeeds, but the execution crashes. The reasons are as follows: Code signature (in/usr/local/Cellar/sdl2/2.0.14 / lib/libSDL2-2.0.0. Dylib) is not valid for use in the process using Liabrary Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed

/usr/local/ffmpeg-lib/dylib = /usr/local/ffmpeg-lib/dylib = /usr/local/ffmpeg-lib/dylib = /usr/local/ffmpeg-lib/dylib Solutions:

Codesign -f -s "Development certificate name" /usr/local/ffmpeg-lib/*.dylibCopy the code

Extend two commands:

Codesign --remove-signature xxx.dylib codesign -v xxx.dylibCopy the code

But after the prompt: error: / Applications/Xcode. The app/Contents/Developer/Toolchains/XcodeDefault xctoolchain/usr/bin/codesign_allocate: can’t create output file: / usr/local/ffmpeg/lib/libavcodec 58.125.100. Dylib. Cstemp (Permission denied) / usr/local/ffmpeg/lib/libavcodec 58.125.100. Dylib: the codesign_allocate helper tool always be found or informs

Change the owner of the /usr/local/ffmpeg directory to the current user and select “Make __ owner” (set in the introduction of the folder) as follows:

/usr/local/ffmpeg-lib/*. Dylib: /usr/local/ffmpeg-lib/*. Dylib: /usr/local/ffmpeg-lib/*. Re-run the project and prompt: Code signature (in/usr/local/Cellar/sdl2/2.0.14 / lib/libSDL2-2.0.0. Dylib) is not valid for use in the process using Liabrary Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed. Repeat the above method ~ and run again, success ~

Attach the common q&a: teacher li chao zhuanlan.zhihu.com/p/128146338