Reference article: www.jianshu.com/p/cd33f4ac1…
needed file
gas-preprocessor
Go to GitHub to download through the above hyperlink, and execute the following command.
- cd download directory such as: cd /Users/ your username /Downloads/gas-preprocessor-master
- sudo cp gas-preprocessor.pl /usr/local/bin
- chmod 777 /usr/local/bin/gas-preprocessor.pl
If the third step fails, you can trychmod +x gas-preprocessor.pl
yasm
No need to download, directly execute the following command
- brew install yasm
- yasm --version
FFmpeg-iOS-build-script
executes the command
- cd download directory such as: cd /Users/ your username /Downloads/FFmpeg-iOS-build-script-master
- ./build-ffmpeg.sh Execution script
- Wait for the compilation to end After the compilation is completed, a latest one will be downloaded
FFmpeg
as shown below
New Construction
- New Construction
- Drag the downloaded
kxmovie
andFFmpeg-iOS
into the project
3. Add the following dependent libraries:
- libz.tbd
- libbz2.tbd
- libiconv.tbd
- VideoToolBox.framework
4. 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];
}
@end
Compilation error solution
1. KxMovieDecoder cannot find UIImage
need ourselves#import <UIKit/UIKit.h>
2. A large number of error messages appear because the VideoToolBox has not been introduced
3. The solution to the error that libavformat/avformat.h cannot be found
Target -> Project -> Build Settings -> Library Search Path Copy the following content
lib
Change the suffix toinclude
$(PROJECT_DIR)/HBFFmpeg/FFmpeg-iOS/include
- Then add to Header Search Path
Original iOS audio and video -- compile FFmpeg
★The business card at the end of the article can receive free audio and video development learning materials, including (FFmpeg, webRTC, rtmp, hls, rtsp, ffplay, srs) and audio and video learning roadmaps, etc.
see below!