ffmpeg rk3568
This commit is contained in:
parent
9bd250ebdf
commit
eee3d4d93e
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.idea
|
||||||
|
.vscode
|
23
cmake.md
23
cmake.md
@ -24,7 +24,7 @@ cmake的使用围绕着 编译选项 头文件 库文件搜索路径,需要编
|
|||||||
```cmake
|
```cmake
|
||||||
set(key value) #定义变量 也可以拼接变量
|
set(key value) #定义变量 也可以拼接变量
|
||||||
# 使用时通过 ${key} 取值
|
# 使用时通过 ${key} 取值
|
||||||
set(变量名1 ${变量名1} ${变量名2} ...)
|
set(变量名1 ${xxx1} ${xxx2} ...)
|
||||||
|
|
||||||
list(APPEND <list> [<element> ...])
|
list(APPEND <list> [<element> ...])
|
||||||
# list 也可以移除
|
# list 也可以移除
|
||||||
@ -39,7 +39,7 @@ add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL])
|
|||||||
|
|
||||||
### cmake中常见的预设变量
|
### cmake中常见的预设变量
|
||||||
|
|
||||||
下面的列表中为大家整理了一些CMake中常用的宏:
|
下面的列表中为一些CMake中常用的宏:
|
||||||
|
|
||||||
| 宏 | 含义 |
|
| 宏 | 含义 |
|
||||||
| ------------------------ | ------------------------------------------------------------ |
|
| ------------------------ | ------------------------------------------------------------ |
|
||||||
@ -221,11 +221,11 @@ target_include_directories(test1 PUBLIC include/test2)
|
|||||||
```cmake
|
```cmake
|
||||||
# 关于条件判断其语法格式如下:
|
# 关于条件判断其语法格式如下:
|
||||||
if(<condition>)
|
if(<condition>)
|
||||||
<commands>
|
# <commands>
|
||||||
elseif(<condition>) # 可选快, 可以重复
|
elseif(<condition>) # 可选快, 可以重复
|
||||||
<commands>
|
#<commands>
|
||||||
else() # 可选快
|
else() # 可选快
|
||||||
<commands>
|
#<commands>
|
||||||
endif()
|
endif()
|
||||||
# 在进行条件判断的时候,如果有多个条件,那么可以写多个elseif,最后一个条件可以使用else,但是开始和结束是必须要成对出现的,分别为:if和endif。
|
# 在进行条件判断的时候,如果有多个条件,那么可以写多个elseif,最后一个条件可以使用else,但是开始和结束是必须要成对出现的,分别为:if和endif。
|
||||||
```
|
```
|
||||||
@ -235,14 +235,14 @@ endif()
|
|||||||
# 基本表达式
|
# 基本表达式
|
||||||
if(<expression>) # NOT AND OR
|
if(<expression>) # NOT AND OR
|
||||||
#]=]
|
#]=]
|
||||||
如果是基本表达式,expression 有以下三种情况:常量、变量、字符串。
|
# 如果是基本表达式,expression 有以下三种情况:常量、变量、字符串。
|
||||||
如果是1, ON, YES, TRUE, Y, 非零值,非空字符串时,条件判断返回True
|
# 如果是1, ON, YES, TRUE, Y, 非零值,非空字符串时,条件判断返回True
|
||||||
如果是 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND,空字符串时,条件判断返回False
|
# 如果是 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND,空字符串时,条件判断返回False
|
||||||
#]=]
|
# ]=]
|
||||||
# 逻辑判断
|
# 逻辑判断
|
||||||
if( <condition>)
|
if( <condition>)
|
||||||
# 其实这就是一个取反操作,如果条件condition为True将返回False,如果条件condition为False将返回True。
|
# 其实这就是一个取反操作,如果条件condition为True将返回False,如果条件condition为False将返回True。
|
||||||
如果cond1和cond2两个条件中至少有一个为True,返回True,如果两个条件都为False则返回False。
|
# 如果cond1和cond2两个条件中至少有一个为True,返回True,如果两个条件都为False则返回False。
|
||||||
```
|
```
|
||||||
比较
|
比较
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ if(<variable|string> STRGREATER_EQUAL <variable|string>)
|
|||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
foreach(<loop_var> <items>)
|
foreach(<loop_var> <items>)
|
||||||
<commands>
|
# <commands>
|
||||||
endforeach()
|
endforeach()
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -315,7 +315,6 @@ project(test)
|
|||||||
foreach(item RANGE 10 30 2)
|
foreach(item RANGE 10 30 2)
|
||||||
message(STATUS "当前遍历的值为: ${item}" )
|
message(STATUS "当前遍历的值为: ${item}" )
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
166
ffmpeg.md
166
ffmpeg.md
@ -72,7 +72,7 @@ sudo make install
|
|||||||
# ./ffmpeg -hwaccels 查看支持哪些硬件编码
|
# ./ffmpeg -hwaccels 查看支持哪些硬件编码
|
||||||
```
|
```
|
||||||
|
|
||||||
**编译ffmeg arm64版本**
|
### 编译ffmeg arm64安卓版本
|
||||||
|
|
||||||
在源码目录下创建buildarm64.sh,内容如下
|
在源码目录下创建buildarm64.sh,内容如下
|
||||||
|
|
||||||
@ -149,6 +149,170 @@ chomd +x buildarm64.sh
|
|||||||
./buildarm64.sh
|
./buildarm64.sh
|
||||||
# 编译好后,对应的源文件和库文件会安装到./android/armv-v8a中
|
# 编译好后,对应的源文件和库文件会安装到./android/armv-v8a中
|
||||||
```
|
```
|
||||||
|
### 在rk3568上交叉编译ffmpeg
|
||||||
|
使用瑞芯微上使用其硬件加速编码和解码
|
||||||
|
创建一个目录 ~/dev 之后所有的操作在这个目录下进行
|
||||||
|
1. 编译mpp
|
||||||
|
```shell
|
||||||
|
git clone -b jellyfin-mpp --depth=1 https://github.com/nyanmisaka/mpp.git rkmpp
|
||||||
|
mkdir rkmpp_build
|
||||||
|
pushd rkmpp_build
|
||||||
|
# 在cmake中指定交叉工具链gcc和g++ 改成自己的目录
|
||||||
|
# 注意在不要安装到本机的系统目录,最好新建一个目录,之后把所有的依赖安装到这个目录
|
||||||
|
cmake \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=~/dev/rkffmpeg \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DBUILD_SHARED_LIBS=ON \
|
||||||
|
-DBUILD_TEST=OFF \
|
||||||
|
-DCMAKE_C_COMPILER=/home/user/baidu/buildroot-cross/gcc_for_rk356x_buildroot/bin/aarch64-linux-gcc \
|
||||||
|
-DCMAKE_CXX_COMPILER=/home/user/baidu/buildroot-cross/gcc_for_rk356x_buildroot/bin/aarch64-linux-g++ \
|
||||||
|
..
|
||||||
|
make -j $(nproc)
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
2. build rga
|
||||||
|
|
||||||
|
创建一个在~/dev 目录下创建cross_file.txt, 将工具链换成自己的,以及安装目录
|
||||||
|
```txt
|
||||||
|
[host_machine]
|
||||||
|
system = 'linux'
|
||||||
|
cpu_family = 'aarch64'
|
||||||
|
cpu = 'armv8-a'
|
||||||
|
endian = 'little'
|
||||||
|
|
||||||
|
[binaries]
|
||||||
|
c = '/home/user/baidu/buildroot-cross/gcc_for_rk356x_buildroot/bin/aarch64-linux-gcc'
|
||||||
|
cpp = '/home/user/baidu/buildroot-cross/gcc_for_rk356x_buildroot/bin/aarch64-linux-g++'
|
||||||
|
ar = '/home/user/baidu/buildroot-cross/gcc_for_rk356x_buildroot/aarch64-rockchip-linux-gnu/bin/ar'
|
||||||
|
strip = '/home/user/baidu/buildroot-cross/gcc_for_rk356x_buildroot/aarch64-rockchip-linux-gnu/bin/strip'
|
||||||
|
|
||||||
|
[properties]
|
||||||
|
c_args = ['-fpermissive']
|
||||||
|
cpp_args = ['-fpermissive']
|
||||||
|
|
||||||
|
[paths]
|
||||||
|
prefix = '~/dev/rkffmpeg'
|
||||||
|
libdir = 'lib'
|
||||||
|
```
|
||||||
|
```shell
|
||||||
|
git clone -b jellyfin-rga --depth=1 https://github.com/nyanmisaka/rk-mirrors.git rkrga
|
||||||
|
# 不需要cd 进行
|
||||||
|
meson setup rkrga rkrga_build \
|
||||||
|
--prefix=/usr \
|
||||||
|
--libdir=lib \
|
||||||
|
--buildtype=release \
|
||||||
|
--default-library=shared \
|
||||||
|
-Dcpp_args=-fpermissive \
|
||||||
|
-Dlibdrm=false \
|
||||||
|
-cross-file=./cross_file.txt \
|
||||||
|
-Dlibrga_demo=false
|
||||||
|
meson configure rkrga_build
|
||||||
|
ninja -C rkrga_build install
|
||||||
|
```
|
||||||
|
3. 编译drm
|
||||||
|
|
||||||
|
首先去官网下载源码包https://dri.freedesktop.org/libdrm/
|
||||||
|
下载完成后,开始解压缩,解压缩完成后,进入源码目录,首先创建install和build目录,然后创建cross_file.txt文件,文件内容如下
|
||||||
|
```txt
|
||||||
|
[host_machine]
|
||||||
|
system = 'linux'
|
||||||
|
cpu_family = 'aarch64'
|
||||||
|
cpu = 'armv8-a'
|
||||||
|
endian = 'little'
|
||||||
|
|
||||||
|
[binaries]
|
||||||
|
c = '/home/user/baidu/buildroot-cross/gcc_for_rk356x_buildroot/bin/aarch64-linux-gcc'
|
||||||
|
cpp = '/home/user/baidu/buildroot-cross/gcc_for_rk356x_buildroot/bin/aarch64-linux-g++'
|
||||||
|
ar = '/home/user/baidu/buildroot-cross/gcc_for_rk356x_buildroot/aarch64-rockchip-linux-gnu/bin/ar'
|
||||||
|
strip = '/home/user/baidu/buildroot-cross/gcc_for_rk356x_buildroot/aarch64-rockchip-linux-gnu/bin/strip'
|
||||||
|
|
||||||
|
[properties]
|
||||||
|
c_args = ['-fpermissive']
|
||||||
|
cpp_args = ['-fpermissive']
|
||||||
|
|
||||||
|
[paths]
|
||||||
|
prefix = '~/dev/rkffmpeg'
|
||||||
|
libdir = 'lib'
|
||||||
|
```
|
||||||
|
然后直接执行指令ninja && ninja install即可使用
|
||||||
|
|
||||||
|
4. 编译ffmpeg
|
||||||
|
|
||||||
|
上面的依赖编译并安装好后,正式开始编译ffmpeg,添加rk芯片的mpp来加速编解码
|
||||||
|
在~/dev 下载ffmpeg 进入到源码目录 创建build.sh 内容如下
|
||||||
|
```shell
|
||||||
|
#!/bin/bash
|
||||||
|
export TOOLCHAIN=/home/user/baidu/buildroot-cross/gcc_for_rk356x_buildroot/bin/aarch64-linux
|
||||||
|
export GCC=$TOOLCHAIN-gcc
|
||||||
|
export GXX=$TOOLCHAIN-g++
|
||||||
|
|
||||||
|
# 编译到开发版,尽可能小一些(--enable-small),取消了一些其它硬件加速和封装
|
||||||
|
# 更换 cc cxx ar strip 以及--extra-cflags --extra-ldflags
|
||||||
|
function build_android
|
||||||
|
{
|
||||||
|
|
||||||
|
./configure \
|
||||||
|
--sysroot=./ \
|
||||||
|
--extra-cflags="-I~/dev/rkffmpeg/include" \
|
||||||
|
--extra-ldflags="-L~/dev/rkffmpeg/lib" \
|
||||||
|
--prefix=$PREFIX \
|
||||||
|
--enable-cross-compile \
|
||||||
|
--arch=arm64 \
|
||||||
|
--cpu=armv8-a \
|
||||||
|
ar=/home/user/baidu/buildroot-cross/gcc_for_rk356x_buildroot/aarch64-rockchip-linux-gnu/bin/ar \
|
||||||
|
strip=/home/user/baidu/buildroot-cross/gcc_for_rk356x_buildroot/aarch64-rockchip-linux-gnu/bin/strip \
|
||||||
|
--cc=$GCC \
|
||||||
|
--cxx=$GXX \
|
||||||
|
--enable-libdrm \
|
||||||
|
--disable-nvenc \
|
||||||
|
--disable-nvdec \
|
||||||
|
--disable-vdpau \
|
||||||
|
--disable-vaapi \
|
||||||
|
--enable-rkmpp \
|
||||||
|
--enable-rkrga \
|
||||||
|
--enable-version3 \
|
||||||
|
--disable-programs \
|
||||||
|
--disable-avdevice \
|
||||||
|
--disable-muxers \
|
||||||
|
--disable-filters \
|
||||||
|
--enable-neon \
|
||||||
|
--enable-gpl \
|
||||||
|
--disable-sdl2 \
|
||||||
|
--disable-postproc \
|
||||||
|
--disable-debug \
|
||||||
|
--enable-small \
|
||||||
|
--enable-static \
|
||||||
|
--enable-shared \
|
||||||
|
--disable-doc \
|
||||||
|
--enable-ffmpeg \
|
||||||
|
--disable-ffprobe \
|
||||||
|
--disable-avdevice \
|
||||||
|
--disable-doc \
|
||||||
|
--disable-symver
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "============================ build android arm64-v8a success =========================="
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#arm64-v8a
|
||||||
|
|
||||||
|
|
||||||
|
PREFIX=$(pwd)/rk-arm64
|
||||||
|
|
||||||
|
build_android
|
||||||
|
```
|
||||||
|
编译
|
||||||
|
```shell
|
||||||
|
chmod +x build.sh
|
||||||
|
|
||||||
|
make clean
|
||||||
|
make -j16
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
最后把编译好的ffmpeg 放到~/dev/rkffmpeg 中 一并打包移植到开发版上
|
||||||
|
|
||||||
|
|
||||||
## 硬编码
|
## 硬编码
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user