# # # to do a live video decoding project RTSP flow testing of class is (monitoring), the end of the project, the record before compiling FFmpeg terrier, said a lot on the Internet how to compile the FFmpeg but look at all like a person, is the same, are copied, but the really very slow to solve the problem, I’m here to summarize, for later time less Detour;

1. Download the following five files gas – preprocessor address https://github.com/applexiaohao/gas-preprocessor

yasm https://github.com/yasm/yasm

FFmpeg-iOS-build-script https://github.com/applexiaohao/FFmpeg-iOS-build-script

ffmpeg http://www.ffmpeg.org/releases/?C=M; O=D

kxmovie https://github.com/applexiaohao/kxmovie

1. Open the terminal and go to the gas-Preprocessor folder

CD drags the file into the carriage returnCopy the code

2. Copy the gas-preprocessor.pl file in the folder to the /usr/sbin/ directory

sudo cp /Users/chenqiang/Downloads/gas-preprocessor-master/gas-preprocessor.pl /usr/local/bin
Copy the code

/usr/local/bin enter sudo cp(this is the address of the gas-preprocessor.pl file, just drag the gas-preprocessor.pl file in)

3. Change the permission of the /usr/sbin/gas-preprocessor.pl file to executable permission if 1. If the command fails, use 2. command

1.
 chmod 777 /usr/sbin/gas-preprocessor.pl
Copy the code
 2.
 chmod +x gas-preprocessor.pl
Copy the code

4. In order to have problems when compiling, we now enter the downloaded yASM folder and install the command yasm by compiling

CD drags the file into the carriage returnCopy the code
 ./configure && make -j 4 && sudo make install
Copy the code

If you did not use Homebrew package Manager in the previous step, first check whether Homebrew Package Manager is installed

Terminal command type brewCopy the code

If the Homebrew Package Manager is not installed

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copy the code

After executing, enter the following command to install yASM

  brew install yasm
Copy the code

Next, execute build-ffmpeg.sh in ffmpeg-ios-build-script-master

CD drag the file ffmpeg-ios-build-script-master in and press enterCopy the code

Build all arm64, armv7, x86_64 static libraries

./build-ffmpeg.sh
Copy the code

If you compile a static library that supports the ARM64 architecture

./build-ffmpeg.sh arm64
Copy the code

If you build a static library for armv7 and x86_64(64-bit simulator)

./build-ffmpeg.sh armv7 x86_64
Copy the code

Or compile the merged version

./build-ffmpeg.sh lipo
Copy the code

The next step is to wait for the terminal to compile itself, which takes about ten minutes

Import the kxMovie file into the project and add the following dependency libraries

Add libz.lib add libbbz2. lib add libbiconv.libCopy the code

The #include “libavformat/avformat.h” header file could not be found

Search library Search PathsChange the suffix to.lib and copy that lib entry and search for Header Search paths in the Setting search boxAdd the suffix “.include “to the file that you just copied. Run and find that the project will not report any errors so FFmpeg will be imported successfully

Introduce #import “kxMovieViewController.h” in the project where the decoder is created

NSString *path = @"http://www.qeebu.com/newe/Public/Attachment/99/52958fdb45565.mp4"; NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; If ([path. PathExtension isEqualToString: @ "WMV]") the parameters [KxMovieParameterMinBufferedDuration] = @ (5.0); if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) parameters[KxMovieParameterDisableDeinterlacing] = @(YES); KxMovieViewController *vc = [KxMovieViewController movieViewControllerWithContentPath:path parameters:parameters]; [self presentViewController:vc animated:YES completion:nil];Copy the code

So you can see what’s playing

### Do not try to decode the application after it enters the root view. I found that this should not be done until after viewDidLoad