[iOS]FFmpeg架構在iOS平台上的編譯和使用

來源:互聯網
上載者:User

標籤:編譯安裝   視頻   brew   include   hex   5.0   cti   terminal   view   

使用環境
  • Mac OS Yosemite 10.10.5
開發工具
  • Xcode 7.0

  • Terminal

需要的檔案連結
  • gas-preprocessor
  • yasm
  • FFmpeg-iOS-build-script
  • ffmpeg-2.8
  • kxmovie
編譯適用於iOS平台的FFmpeg靜態庫
  • 開啟終端Terminal進入下載後的gas-preprocessor檔案夾

    • 將檔案夾內的gas-preprocessor.pl檔案拷貝到/usr/sbin/目錄下

    • 修改/usr/sbin/gas-preprocessor.pl的檔案許可權為可執行許可權

        chmod 777 /usr/sbin/gas-preprocessor.pl
  • 執行FFmpeg-iOS-build-script-master檔案夾內的build-ffmpeg.sh

    • 編譯所有的版本arm64armv7x86_64的靜態庫

      ./build-ffmpeg.sh
    • 編譯支援arm64架構的靜態庫

      ./build-ffmpeg.sh arm64
    • 編譯適用於armv7x86_64(64-bit simulator)的靜態庫

      ./build-ffmpeg.sh armv7 x86_64
    • 編譯合并的版本

      ./build-ffmpeg.sh lipo
編譯靜態庫遇到的問題
  • yasm沒有安裝的情況

    • 解決方案1

      • 進入下載後的yasm檔案夾,通過編譯安裝命令yasm

          ./configure && make -j 4 && sudo make install
    • 解決方案2

      • 使用Homebrew包管理器,進行安裝

          brew install yasm
    • 測試是否安裝成功

        yasm --verision
  • c test failed的情況

    • xcode環境安裝過多,使用xcode-select選擇預設的工具路徑/Applications/Xcode-beta.app

        sudo xcode-select -s /Applications/Xcode-beta.app
使用編譯完成的 FFmpeg靜態庫
  • 編譯成功後,即可將FFmpeg-iOS檔案夾(包含include和lib)引入到Xcode內

  • 加入依賴庫libz.lib

  • 加入依賴庫libbz2.lib

  • 加入依賴庫libiconv.lib

  • 如有編譯錯誤,連結檔案不存在

      修改Build Setting   Header Search Paths = $(SRCROOT)/LOFFmpegSample/FFmpeg-iOS/include
使用架構 kxmovie播放視頻
    NSString *path = @"";    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];    // increase buffering for .wmv, it solves problem with delaying audio frames    if ([path.pathExtension isEqualToString:@"wmv"])        parameters[KxMovieParameterMinBufferedDuration] = @(5.0);    // disable deinterlacing for iPhone, because it‘s complex operation can cause stuttering    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)        parameters[KxMovieParameterDisableDeinterlacing] = @(YES);    KxMovieViewController *vc = [KxMovieViewController movieViewControllerWithContentPath:path                                                                               parameters:parameters];    [self presentViewController:vc animated:YES completion:nil];

執行個體工程:
LOFFmpeg

[iOS]FFmpeg架構在iOS平台上的編譯和使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.