FFmpeg在iOS上完美編譯

來源:互聯網
上載者:User

標籤:

最近剛接觸ffmpeg,找了很多相關的編譯資料,都沒有編譯成功,前幾天在 github上找到一個指令碼(https://github.com/kewlbear/FFmpeg-iOS-build-script),就可完美編譯

具體步驟如下:

1.下載指令碼:https://github.com/kewlbear/FFmpeg-iOS-build-script,要運行這個指令碼,

準備條件:

  • 先下載檔案:https://github.com/libav/gas-preprocessor,
  • 複製gas-preprocessor.pl到/usr/sbin下,
  • chmod 777 /usr/local/bin/gas-preprocessor.pl

2. 解壓,找到檔案 build-ffmpeg.sh

3. 執行服本檔案:./build-ffmpeg.sh, 注意安裝這個服本時可能會出錯,

如下:MAC:FFmpeg-iOS-build-script-master-2 jinsonglnan$ ./build-ffmpeg.sh 
Yasm not found
Homebrew not found. Trying to install...
Whoops, the Homebrew installer has moved! Please instead run:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Also, please ask wherever you got this link from to update it to the above.
Trying to install Yasm...
./build-ffmpeg.sh: line 67: brew: command not found 

意思就是說,沒有yasm, 看到提示執行 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安裝

4.編譯完成後,終端進入FFmpeg-iOS-build-script目錄,然後輸入./build-ffmpeg.sh lipo,這個命令是講.a檔案合并成一個

5.把ffmpeg-iOS檔案加入到工程中

6.添加一個標頭檔引用 #include "avformat.h"

添加一個api語句:av_register_all();給一個類檔案.m尾碼改為.mm,開啟混編模式。

運行工程,如果沒有報錯,則表明編譯成功

7.其他注意細節

如 編譯的時候報錯: ‘libavcodec/avcodec.h‘ file not found ,修改Header search paths 裡的路徑:$(PROJECT_DIR)/FFmpeg-iOS/include


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.