Ubuntu 18.04 编译 ijkplayer 1. 配置安装源 https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu 2. 配置好安装源后,安装一些组件 $ sudo apt update $ sudo apt install vim openssh-server git curl wget tar unzip $ sudo apt install build-essential openjdk-8-jdk yasm python 3. 下载sdk-manager https://developer.android.com $ wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip 如果在Windows,可通过putty的psftp复制sdk-tools-linux-3859397.zip到linux系统 4. 解压sdk-manager $ unzip ~/sdk-tools-linux-3859397.zip -d ~/android-sdk 5. 更新tools $ touch ~/.android/repositories.cfg // 可忽略 $ ./sdkmanager --update 提示许可协议,输入y回车,然后耐心等待,提示done表示完成。 6. 查看可安装列表 $ cd ~/android-sdk/tools/bin $ ./sdkmanager --list 记住最新的sdk build tools 7. 安装sdk build-tools和ndk $ cd ~/android-sdk/tools/bin $ ./sdkmanager "build-tools;27.0.3" // "ndk-bundle" 下载14版本的NDK $ cd ~ $ wget https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip $ unzip android-ndk-r14b-linux-x86_64.zip -d ~/android-sdk 8. 删除无用的压缩包,备份android-sdk目录 $ cd ~ $ rm ~/sdk-tools-linux-3859397.zip ~/android-ndk-r14b-linux-x86_64.zip $ tar cvzf android-sdk-ndkr14b.tar.gz android-sdk 编译ijkplayer项目 一、准备源码 https://github.com/Bilibili/ijkplayer#build-android 1. 配置环境变量 $ export ANDROID_SDK=$HOME/android-sdk // $ export ANDROID_NDK=$ANDROID_SDK/ndk-bundle //此项目最高支持NDK14的版本,因此用下面的位置。 $ export ANDROID_NDK=$ANDROID_SDK/android-ndk-r14b 2. 下载ijkplayer源代码 $ cd ~ $ git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-android $ cd ijkplayer-android $ git checkout -B latest k0.8.8 3. 下载相关的android ffmpeg源代码 $ ./init-android.sh 4. 备份源码 $ cd ~ $ tar cvzf ijkplayer-android.tar.gz ijkplayer-android 二、编译 1. 用bash代替dash $ sudo dpkg-reconfigure dash 选择NO 如果新打开的shell,记得按“一1”配置ANDROID_SDK和ANDROID_NDK环境变量。 2. 选择解码包 (1)默认是较少的codec/format生成较小尺寸的包。 (2)在(1)的基础上包含hevc功能 (3)最多的codec/format 如果选择(1)请直接到下一步。否则继续操作: $ cd ~/ijkplayer-android/config $ rm module.sh $ ln -s module-lite-hevc.sh module.sh <<<< (2) $ ln -s module-default.sh module.sh <<<< (3) 注意,选择(2)需要为ffmpeg额外安装latm,选择(3)可能需要手动安装更多的外部库。 3. 编译ffmepg $ cd ~/ijkplayer-android/android/contrib $ ./compile-ffmpeg.sh clean $ ./compile-ffmpeg.sh all 成功进行下一步。 如果报错:fatal error: linux/perf_event.h: No such file or directory $ vim ~/ijkplayer-android/config/module.sh 在结尾加入这一行: export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-linux-perf" 保存后执行 $ ./compile-ffmpeg.sh clean $ ./compile-ffmpeg.sh all 4. 编译ijkplayer $ cd ~/ijkplayer-android/android $ ./compile-ijk.sh all 5. 备份成果 $ cd ~ $ tar cvzf ijkplayer-android-build.tar.gz ijkplayer-android 三、使用 # Android Studio: # Open an existing Android Studio project # Select android/ijkplayer/ and import # # define ext block in your root build.gradle # ext { # compileSdkVersion = 23 // depending on your sdk version # buildToolsVersion = "23.0.0" // depending on your build tools version # # targetSdkVersion = 23 // depending on your sdk version # } # # If you want to enable debugging ijkplayer(native modules) on Android Studio 2.2+: (experimental) # sh android/patch-debugging-with-lldb.sh armv7a # Install Android Studio 2.2(+) # Preference -> Android SDK -> SDK Tools # Select (LLDB, NDK, Android SDK Build-tools,Cmake) and install # Open an existing Android Studio project # Select android/ijkplayer # Sync Project with Gradle Files # Run -> Edit Configurations -> Debugger -> Symbol Directories # Add "ijkplayer-armv7a/.externalNativeBuild/ndkBuild/release/obj/local/armeabi-v7a" to Symbol Directories # Run -> Debug ‘ijkplayer-example‘ # if you want to reverse patches: # sh patch-debugging-with-lldb.sh reverse armv7a # # Eclipse: (obselete) # File -> New -> Project -> Android Project from Existing Code # Select android/ and import all project # Import appcompat-v7 # Import preference-v7 # # Gradle # cd ijkplayer # gradle
原文地址:https://www.cnblogs.com/Bob-wei/p/9089778.html
时间: 2024-10-08 07:19:43