Refer to the article: www.jianshu.com/p/cd33f4ac1…

Required documents

gas-preprocessor

yasm

FFmpeg-iOS-build-script

kxmovie

gas-preprocessor

Go to GitHub and run the following command.

  1. CD Download directory: CD /Users/ Your user name /Downloads/gas-preprocessor-master
  2. sudo cp gas-preprocessor.pl /usr/local/bin
  3. chmod 777 /usr/local/bin/gas-preprocessor.pl

If step 3 fails, try chmod +x gas-preprocessor.pl

yasm

Run the following command without downloading

  1. brew install yasm
  2. yasm –version

FFmpeg-iOS-build-script

Execute the command

  1. CD Download directory: CD /Users/ your user name /Downloads/ ffmpeg-ios-build-script-master
  2. /build-ffmpeg.sh Executes the script
  3. Wait until the compile is complete. After the compile is complete, the latest one will be downloadedFFmpegThe following figure

New construction

  1. New construction
  2. To download thekxmovieAs well asFFmpeg-iOSInto the project



libz.tbd



libbz2.tbd



libiconv.tbd



VideoToolBox.framework

  1. Add running code
#import "ViewController.h" #import "KxMovieViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; } -(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; NSString *urlStr = @"https://vd3.bdstatic.com/mda-ja0k1pw5mvhn0rzh/mda-ja0k1pw5mvhn0rzh.mp4"; NSMutableDictionary *param = [NSMutableDictionary dictionary]; If ([urlStr pathExtension isEqualToString: @ ""]) {param [KxMovieParameterMinBufferedDuration] = @ (5.0); } if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { param[KxMovieParameterDisableDeinterlacing] = @(YES); } KxMovieViewController *vc = [KxMovieViewController movieViewControllerWithContentPath:urlStr parameters:param]; vc.modalPresentationStyle = UIModalPresentationFullScreen; [self presentViewController:vc animated:YES completion:nil]; } @endCopy the code

Compile error resolution

1.KxMovieDecoder could not find UIImage

#import

2. A large number of error messages appeared, because VideoToolBox was not introduced

3. The libavformat/avformat.h solution cannot be found

  1. Target -> Project -> Build Settings -> Library Search Path copy the following

    $(PROJECT_DIR)/HBFFmpeg/FFmpeg-iOS/lib

  1. The suffixlibInstead ofinclude $(PROJECT_DIR)/HBFFmpeg/FFmpeg-iOS/include
  2. Then add it to the Header Search Path