iOS audio and video -- compile FFmpeg

Reference article: www.jianshu.com/p/cd33f4ac1…

needed file

gas-preprocessor

yasm

FFmpeg-iOS-build-script

kxmovie

gas-preprocessor

Go to GitHub to download through the above hyperlink, and execute the following command.

  1. cd download directory such as: cd /Users/ your username /Downloads/gas-preprocessor-master
  2. sudo cp gas-preprocessor.pl /usr/local/bin
  3. 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

  1. brew install yasm
  2. yasm --version

FFmpeg-iOS-build-script
executes the command

  1. cd download directory such as: cd /Users/ your username /Downloads/FFmpeg-iOS-build-script-master
  2. ./build-ffmpeg.sh Execution script
  3. Wait for the compilation to end After the compilation is completed, a latest one will be downloaded FFmpegas shown below

New Construction

  1. New Construction
  2. Drag the downloaded kxmovie and  FFmpeg-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

  1. libChange the suffix toinclude$(PROJECT_DIR)/HBFFmpeg/FFmpeg-iOS/include
  2. 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!

 

Guess you like

Origin blog.csdn.net/yinshipin007/article/details/131731471