How to build ffmpeg with hardware accelerated codecs for Android x86

来源:https://www.cnblogs.com/Jedimaster/archive/2019/03/22/10578983.html
-Advertisement-
Play Games

In order to build a complete ffmpeg with hardware acceleration for Intel platform (XXX lake + Atom), we need a complete Android x86 build, the cross-c ...


In order to build a complete ffmpeg with hardware acceleration for Intel platform (XXX lake + Atom), we need a complete Android x86 build, the cross-compilation doesn't work well with NDK or anything else.

Steps are below.


 Install Ubuntu 16.04 LTS x86-64, install the all Ubuntu dependencies as here.

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip

Install Python Mako by pip, which the build system uses to generate the i18n files during compilation.

sudo apt-get install python-pip

pip install mako

Get the source code of Android x86, here make sure you have large enough space.

mkdir android-x86
cd android-x86
repo init -u git://git.osdn.net/gitroot/android-x86/manifest -b $branch
repo sync --no-tags --no-clone-bundle

The variable $branch is the name of specific Android branch.

  • oreo-x86
    • Android 8.0
  • nougat-x86
    • Android 7.1
  • marshmallow-x86
    • Android 6.0
  • lollipop-x86
    • Android 5.1
  • kitkat-x86
    • Android 4.4
  • jb-x86
    • Android 4.3
  • ics-x86
    • Android 4.0
  • honeycomb-x86
    • Android 3.2
  • gingerbread-x86
    • Android 2.3
  • froyo-x86
    • Android 2.2
  • eclair-x86
    • Android 2.1
  • donut-x86
    • Android 1.6
  • cupcake-x86 (aka android-x86-v0.9)
    • Android 1.5

Once the code base was checked out, use lunch command to build the system for once.

Enter the folder of checked out folder.

Source the build environement setup.

. build/envsetup.sh

Select the build target and type of build

lunch $TARGET_PRODUCT-$TARGET_BUILD_VARIANT

The $TARGET_PRODUCT could be one of android_x86 android_x86_64 .

The $TARGET_BUILD_VARIANT could be one of eng user userdebug .

So if we want to make a debug version of Android x86-64, we type

lunch android_x86_64-userdebug

Now type

m -jX iso_img

to make the system image.

When there is the error about org.android.analytics, open the file

./build/core/tasks/check_boot_jars/package_whitelist.txt

 and append a line

org\.android_x86\.analytics

to it.

If everything goes okay, the Android system image would be build.


 Now we start to build a better ffmpeg with hardware acceleration API, vaapi, cuvid etc. The system already offer the possibilty but didn't supply the correct configuration as the default.

Copy the file

external/ffmpeg/libavformat/Android.mk

to

external/ffmpeg/libavfilter

If you want to build the command line of ffmpeg, create a new Android.mk file under external/tools folder, fill it with content

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_CFLAGS += \
  -DANDROID \
  -DTARGET_CONFIG=\"config-x86_64-x86_64.h\" \

LOCAL_SRC_FILES := \
    ../ffmpeg.c \
    ../ffmpeg_filter.c \
    ../ffmpeg_opt.c \
    ../ffmpeg_cuvid.c \
    ../ffmpeg_vaapi.c \
    ../cmdutils.c \

LOCAL_C_INCLUDES += \
  $(LOCAL_PATH)/android/include \
  $(LOCAL_PATH)/.. \

LOCAL_SHARED_LIBRARIES := libavutil libavcodec libswscale libswresample libswscale libavformat libavfilter

LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := ffmpeg

include $(BUILD_EXECUTABLE)

Then that's it, you would have the ffmpeg command line under /system/bin/ffmpeg !

Do not touch the script gen-android-configs and configure with ffmpeg.

Now let's add more dependency to the system, such as libva-utils for the Intel platform to detect the video codec capability of the system.

Under the folder external, clone the repository at branch 1.8.3

git clone -b 1.8.3 https://github.com/intel/libva-utils.git

Enter the libva-utils folder, change a bit the source code. The system's libva under driver is 1.1.0, it's not very compatible with the libva-utils, which is a new program.

diff --git a/vainfo/vainfo.c b/vainfo/vainfo.c
index 4405073..5d9f055 100644
--- a/vainfo/vainfo.c
+++ b/vainfo/vainfo.c
@@ -97,7 +97,8 @@ int main(int argc, const char* argv[])
   const char *name = strrchr(argv[0], '/'); 
   VAProfile profile, *profile_list = NULL;
   int num_profiles, max_num_profiles, i;
-  VAEntrypoint entrypoint, entrypoints[10];
+  VAEntrypoint entrypoints[10];
+  int entrypoint_index;
   int num_entrypoint;
   int ret_val = 0;
   
@@ -118,8 +119,8 @@ int main(int argc, const char* argv[])
   va_status = vaInitialize(va_dpy, &major_version, &minor_version);
   CHECK_VASTATUS(va_status, "vaInitialize", 3);
   
-  printf("%s: VA-API version: %d.%d (libva %s)\n",
-         name, major_version, minor_version, LIBVA_VERSION_S);
+  printf("%s: VA-API version: %d.%d\n",
+         name, major_version, minor_version);
 
   driver = vaQueryVendorString(va_dpy);
   printf("%s: Driver version: %s\n", name, driver ? driver : "<unknown>");
@@ -149,8 +150,8 @@ int main(int argc, const char* argv[])
       CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints", 4);
 
       profile_str = profile_string(profile);
-      for (entrypoint = 0; entrypoint < num_entrypoint; entrypoint++)
-          printf("      %-32s: %s\n", profile_str, entrypoint_string(entrypoints[entrypoint]));
+      for (entrypoint_index = 0; entrypoint_index < num_entrypoint; entrypoint_index++)
+          printf("      %-32s: %s\n", profile_str, entrypoint_string(entrypoints[entrypoint_index]));

Just make the vainfo.c is able to be compiled with system libva.

Back to the folder android-x86, type

mmm external/libva-utils

to just build the specific module. That's it, now the /system/bin/vainfo would be there !


References

  • http://www.android-x86.org/getsourcecode
  • https://github.com/CyanogenMod/android_external_ffmpeg
  • https://github.com/intel/libva
  • https://github.com/intel/libva-utils

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 一.select高級用法 1.傳統連接(只能內連接,取交集,效率最慢) 1.根據兩張表查詢張三成績 2.世界上小於100人的人口城市是哪個國家的 2.NATURAL JOIN(自連接的表要有共同的列名字) 1.查詢,人口在100以上的城市名字,和所說的語言 3.企業中多表連接查詢(內連接) 1.都到 ...
  • 在1年前,我用學生價租了一個阿裡雲伺服器(是真的便宜啊),自己在CentOS系統上用命令行搭了個WordPress的環境,開始了為期一個月使用自建博客的歷程。 事實證明,博客在類似博客園這樣的平臺上寫還是非常方便的! + 不用自己優化後臺,雖然WordPress已經足夠傻瓜了,但是我還是太菜了 + ...
  • Insert,delete,update對btre索引的影響 對需要跟蹤的索引進行監控 Alter index 索引名 monitoring usage; 對需要跟蹤的索引取消監控 Alter index 索引名 nomonitoring usage; 通過觀察v$object_usage進行跟蹤 ...
  • 一、大數據存儲和計算的各種框架即工具 1.存儲:HDFS:分散式文件系統 Hbase:分散式資料庫系統 Kafka:分散式消息緩存系統 2.計算:Mapreduce:離線計算框架 storm:實時流式計算 spark:離線批處理/實時流處理計算框架(MR的二次封裝) 3.輔助類工具:hive:數據倉 ...
  • 一.客戶端與服務端模型 1.mysql是一個典型的c/s服務結構 1.mysql自帶的客戶端程式(/application/mysql/bin) mysql mysqladmin mysqldump 2.市面上大部分的開發語言都需要一個客戶端連接程式連接mysql的服務端 2.mysql是一個守護進 ...
  • 一.Mysql安裝方式 1.安裝方式 1.rpm,yum安裝 安裝方便,安裝速度快,但無法定製 2.二進位安裝 不需要安裝,解壓即用,不能定製功能 3.編譯安裝 可定製,安裝很慢,安裝分為四個步驟 1.1 解壓(tar) 1.2 生成(./configure)或者cmake 1.3 編譯(make) ...
  • 應用程式慢如牛,原因多多,可能是網路的原因、可能是系統架構的原因,還有可能是資料庫的原因。 那麼如何提高資料庫SQL語句執行速度呢?有人會說性能調優是資料庫管理員(DBA)的事,然而性能調優跟程式員們也有莫大的關係 程式中嵌入的一行行的SQL語句,如果使用了一些優化小技巧,定能達到事半功倍的效果... ...
  • Mysql常用命令 啟動 net start mysql 關閉 net stop mysql 連接mysql mysql uroot ppssword mysql uroot P3307 ppssword 修改密碼 mysqladmin uroot p123456 password 123 增加用戶 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...