RV1126平台搭建推流开发环境

RV1126平台搭建推流开发环境 Keith_Cheung 2024-01-09 17:35:19 322

我的交叉编译器的地址:

/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-

一、libx264交叉编译

进入libx264-git目录开始交叉编译,这里要注意–cross-prefix交叉工具链地址,也就是放在sdk里面的位置,这里我位置仅供参考(后面的交叉工具链地址都是这个):

开始交叉编译配置:

./configure --prefix=/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- --enable-shared




./configure --prefix=/opt/arm_libx264 --host=arm-linux --cross-prefix=/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- --enable-shared --disable-static
liefyuan@ubuntu:~/rv1126/3th_lib/ffmpeg_lib/libx264-git$ ./configure --prefix=/opt/arm_libx264 --host=arm-linux --cross-prefix=/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- --enable-shared --disable-static
Unknown option --disable-static, ignored
platform:      ARM
byte order:    little-endian
system:        LINUX
cli:           yes
libx264:       internal
shared:        yes
static:        no
asm:           yes
interlaced:    yes
avs:           avxsynth
lavf:          no
ffms:          no
mp4:           no
gpl:           yes
thread:        posix
opencl:        yes
filters:       crop select_every 
debug:         no
gprof:         no
strip:         no
PIC:           yes
bit depth:     8
chroma format: all

You can run 'make' or 'make fprofiled' now.

然后进行交叉编译:

make -j16
sudo make install

二、libx265交叉编译

步骤一:
解压libx265.tar.gz压缩包

步骤二:
修改CMakeList.txt文件

路径在:vim currrnt_dir/libx265-git/source/CMakeLists.txt

在文件头部添加以下信息:

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR arm)
SET(CMAKE_C_COMPILER "/home/hao/shared/rv1126_rv1109_linux_sdk_v1.8.0_20210224/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc")
SET(CMAKE_CXX_COMPILER "/home/hao/shared/rv1126_rv1109_linux_sdk_v1.8.0_20210224/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++")
set(CMAKE_EXE_LINKER_FLAGS "-ldl")
#set(CMAKE_CXX_FLAGS -ldl)
add_compile_options(-fPIC)

步骤三:

mkdir currrnt_dir/libx265-git/source/build

进入:cd currrnt_dir/libx265-git/source/build

cmake -DCMAKE_INSTALL_PREFIX=/opt/arm_libx265_install ..

make -j32

sudo make install

修改cmake文件:/libx265-git/source/CMakeLists.txt
在文件头部添加如下信息:

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR arm)
SET(CMAKE_C_COMPILER "/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc")
SET(CMAKE_CXX_COMPILER "/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++")
set(CMAKE_EXE_LINKER_FLAGS "-ldl")
#set(CMAKE_CXX_FLAGS -ldl)
add_compile_options(-fPIC)

建立build文件夹,并进入该文件夹下,同时进行编译
运行命令:

cmake -DCMAKE_INSTALL_PREFIX=/opt/arm_libx265_install ..

然后进行编译安装

make -j16
make install

编译报错
1、报错一:

...
/home/liefyuan/rv1126/3th_lib/ffmpeg_lib/libx265-git/source/common/param.cpp:1419:47: error: unable to find string literal operatoroperator""cliopt’ withconst char [4]’, ‘unsigned int’ arguments
     s += sprintf(s, " %s", (param) ? cliopt : "no-"cliopt);
                                               ^~~~~~~~~~~
/home/liefyuan/rv1126/3th_lib/ffmpeg_lib/libx265-git/source/common/param.cpp:1478:5: note: in expansion of macro ‘BOOL’
     BOOL(p->bBPyramid, "b-pyramid");
     ^~~~
/home/liefyuan/rv1126/3th_lib/ffmpeg_lib/libx265-git/source/common/param.cpp:1419:47: error: unable to find string literal operatoroperator""cliopt’ withconst char [4]’, ‘unsigned int’ arguments
     s += sprintf(s, " %s", (param) ? cliopt : "no-"cliopt);
                                               ^~~~~~~~~~~
/home/liefyuan/rv1126/3th_lib/ffmpeg_lib/libx265-git/source/common/param.cpp:1479:5: note: in expansion of macro ‘BOOL’
     BOOL(p->rc.cuTree, "cutree");
     ^~~~
/home/liefyuan/rv1126/3th_lib/ffmpeg_lib/libx265-git/source/common/param.cpp:1419:47: error: unable to find string literal operatoroperator""cliopt’ withconst char [4]’, ‘unsigned int’ arguments
     s += sprintf(s, " %s", (param) ? cliopt : "no-"cliopt);
                                               ^~~~~~~~~~~
...
CMakeFiles/Makefile2:262: recipe for target 'encoder/CMakeFiles/encoder.dir/all' failed
make[1]: *** [encoder/CMakeFiles/encoder.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:317: recipe for target 'common/CMakeFiles/common.dir/all' failed
make[1]: *** [common/CMakeFiles/common.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

编辑文件:

vim /home/liefyuan/rv1126/3th_lib/ffmpeg_lib/libx265-git/source/common/param.cpp 

1418gg

由下面

#define BOOL(param, cliopt) \
    s += sprintf(s, " %s", (param) ? cliopt : "no-"cliopt);

改成这样

#define BOOL(param, cliopt) \
    s += sprintf(s, " %s", (param) ? cliopt : " no- " cliopt);

2、报错二:

/home/liefyuan/rv1126/3th_lib/ffmpeg_lib/libx265-git/source/encoder/ratecontrol.cpp:56:28: error: unable to find string literal operator ‘operator""opt’ with ‘const char [4]’, ‘unsigned int’ arguments
     char* q = strstr(opts, "no-"opt);\
                            ^~~~~~~~
/home/liefyuan/rv1126/3th_lib/ffmpeg_lib/libx265-git/source/encoder/ratecontrol.cpp:453:17: note: in expansion of macro ‘CMP_OPT_FIRST_PASS’
                 CMP_OPT_FIRST_PASS("keyint", m_param->keyframeMax);
                 ^~~~~~~~~~~~~~~~~~
/home/liefyuan/rv1126/3th_lib/ffmpeg_lib/libx265-git/source/encoder/ratecontrol.cpp:56:28: error: unable to find string literal operator ‘operator""opt’ with ‘const char [4]’, ‘unsigned int’ arguments
     char* q = strstr(opts, "no-"opt);\
                            ^~~~~~~~
/home/liefyuan/rv1126/3th_lib/ffmpeg_lib/libx265-git/source/encoder/ratecontrol.cpp:454:17: note: in expansion of macro ‘CMP_OPT_FIRST_PASS’
                 CMP_OPT_FIRST_PASS("scenecut", m_param->scenecutThreshold);
                 ^~~~~~~~~~~~~~~~~~
/home/liefyuan/rv1126/3th_lib/ffmpeg_lib/libx265-git/source/encoder/ratecontrol.cpp:56:28: error: unable to find string literal operator ‘operator""opt’ with ‘const char [4]’, ‘unsigned int’ arguments
     char* q = strstr(opts, "no-"opt);\
                            ^~~~~~~~
/home/liefyuan/rv1126/3th_lib/ffmpeg_lib/libx265-git/source/encoder/ratecontrol.cpp:455:17: note: in expansion of macro ‘CMP_OPT_FIRST_PASS’
                 CMP_OPT_FIRST_PASS("intra-refresh", m_param->bIntraRefresh);
common/CMakeFiles/common.dir/build.make:494: recipe for target 'common/CMakeFiles/common.dir/param.cpp.o' failed
make[2]: *** [common/CMakeFiles/common.dir/param.cpp.o] Error 1
CMakeFiles/Makefile2:317: recipe for target 'common/CMakeFiles/common.dir/all' failed
make[1]: *** [common/CMakeFiles/common.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
encoder/CMakeFiles/encoder.dir/build.make:374: recipe for target 'encoder/CMakeFiles/encoder.dir/ratecontrol.cpp.o' failed
make[2]: *** [encoder/CMakeFiles/encoder.dir/ratecontrol.cpp.o] Error 1
CMakeFiles/Makefile2:262: recipe for target 'encoder/CMakeFiles/encoder.dir/all' failed
make[1]: *** [encoder/CMakeFiles/encoder.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

和上面的错误一样,改那个文件的那个地方,加三个空格,"no-"改为" no- "

然后就编译成功了!

In file included from /home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/vector:69,
                 from /home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/queue:61,
                 from /home/liefyuan/rv1126/3th_lib/ffmpeg_lib/libx265-git/source/x265.cpp:52:
/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/bits/vector.tcc: In member function ‘void std::vector<_Tp, _Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator, _Args&& ...) [with _Args = {long long int}; _Tp = long long int; _Alloc = std::allocator<long long int>]’:
/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/bits/vector.tcc:413:7: note: parameter passing for argument of type ‘std::vector<long long int, std::allocator<long long int> >::iterator’ {aka ‘__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int, std::allocator<long long int> > >’} changed in GCC 7.1
       vector<_Tp, _Alloc>::
       ^~~~~~~~~~~~~~~~~~~
/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/bits/vector.tcc: In function ‘int main(int, char**)’:
/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/bits/vector.tcc:109:4: note: parameter passing for argument of type ‘__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int, std::allocator<long long int> > >’ changed in GCC 7.1
    _M_realloc_insert(end(), std::forward<_Args>(__args)...);
    ^~~~~~~~~~~~~~~~~
/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/bits/vector.tcc:109:4: note: parameter passing for argument of type ‘__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int, std::allocator<long long int> > >’ changed in GCC 7.1
    _M_realloc_insert(end(), std::forward<_Args>(__args)...);
    ^~~~~~~~~~~~~~~~~
[100%] Linking CXX executable x265
[100%] Built target cli

编译成功后记得安装make install。

三、openssl交叉编译

下载openssl源码:

wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1f.tar.gz

解压:

tar -zxvf openssl-1.1.1f.tar.gz

进入目录

cd openssl-1.1.1f/

配置

./config no-asm shared no-async --prefix=/opt/arm_openssl --cross-compile-prefix=/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-

编译

make

安装

sudo make install

报错:arm-linux-gnueabihf-gcc: error: unrecognized command line option ‘-m64’
解决方法:在顶层的Makefile中,找到有 ‘-m64’的地方(两处),将其删除。

四、libsrt交叉编译

把openssl的交叉编译库拷贝到

打开openssl的lib目录:

root@ubuntu:/opt/arm_openssl/lib# ls
engines  engines-1.1  libcrypto.a  libcrypto.so  libcrypto.so.1.0.0  libssl.a  libssl.so  libssl.so.1.0.0  pkgconfig

打开Openssl的include目录
把openssl目录拷贝到srt/haicrypt目录下

cp -r openssl/ /home/liefyuan/rv1126/3th_lib/ffmpeg_lib/srt/haicrypt

进入srt目录下进行配置
先删除CMakeCache.txt文件,再配置

./configure --prefix=/opt/arm_libsrt --openssl-include-dir=/opt/arm_openssl/include --openssl-ssl-library=/opt/arm_openssl/lib --with-compiler-prefix=/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-

配置的时候出现错误:bash: ./configure: /usr/bin/tclsh: bad interpreter: No such file or directory

liefyuan@ubuntu:~/rv1126/3th_lib/ffmpeg_lib/srt$ ./configure --prefix=/opt/arm_libsrt --openssl-include-dir=/opt/arm_openssl/include --openssl-ssl-library=/opt/arm_openssl/lib --with-compiler-prefix=/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
bash: ./configure: /usr/bin/tclsh: bad interpreter: No such file or directory

需要安装一下tclsh:apt install tclsh 配置就没有什么问题了。

然后编译、安装

make -j16
sudo make install

五、ffmpeg交叉编译

第一步配置:

./configure --prefix=/opt/arm_ffmpeg --enable-cross-compile --cross-prefix=/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- --arch=armv7-a --target-os=linux --enable-gpl --enable-nonfree --extra-cflags="-I/opt/arm_libx264/include" --extra-ldflags="-L/opt/arm_libx264/lib " --enable-libx264 --extra-libs="-ldl -fpic -shared" --enable-shared --pkg-config-flags=--static

这个配置编译安装以后,在安装目录生成arm_ffmpeg文件夹。

需要输出H265/PKG-CONFIG路径

export PKG_CONFIG_PATH=/opt/arm_libx265_install/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/opt/arm_libx264/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/opt/arm_libsrt/lib/pkgconfig:$PKG_CONFIG_PATH

Libx264和Libsrt交叉编译

./configure --prefix=/opt/arm32_ffmpeg_srt  --cross-prefix=/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- --enable-cross-compile --target-os=linux --cc=/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc --arch=arm  --enable-shared --disable-static --enable-ffmpeg --extra-cflags=-I/opt/arm_libsrt/include --extra-cflags=-I/opt/arm_libx264/include --extra-ldflags=-L/opt/arm_libx264/lib --extra-ldflags=-L/opt/arm_libsrt/lib --enable-libx264 --enable-gpl --extra-libs="-lm -lsrt -lssl -ldl -lcrypto"


./configure --prefix=/opt/arm32_ffmpeg_srt  --cross-prefix=/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- --enable-cross-compile --target-os=linux --cc=/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc --arch=arm  --enable-shared --disable-static --enable-ffmpeg --extra-cflags=-I/opt/arm_libsrt/include --extra-cflags=-I/opt/arm_libx264/include --extra-cflags=-I/opt/arm_libx265/include --extra-ldflags=-L/opt/arm_libx264/lib --extra-ldflags=-L/opt/arm_libx265/lib  --enable-libx264 --enable-libx265 --enable-gpl --pkg-config="pkg-config --static"


./configure --prefix=/opt/arm32_ffmpeg_srt  --cross-prefix=/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf- --enable-cross-compile --target-os=linux --cc=/home/liefyuan/rv1126/RV1126_RV1109_LINUX_SDK_V2.1.0_20210512/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc --arch=arm  --enable-shared --disable-static --enable-ffmpeg --extra-cflags=-I/opt/arm_libsrt/include --extra-cflags=-I/opt/arm_libx264/include --extra-cflags=-I/opt/arm_libx265_install/include --extra-ldflags=-L/opt/arm_libx264/lib --extra-ldflags=-L/opt/arm_libx265_install/lib --extra-cflags=-I/opt/arm_libsrt/include --extra-ldflags=-L/opt/arm_libsrt/lib --enable-libsrt --enable-libx264 --enable-libx265 --enable-gpl --pkg-config="pkg-config --static" --extra-libs="-ldl"

建议使用第三个配置,最终编译安装后会在安装目录生成arm32_ffmpeg_srt文件夹

第二步:make

第三步:make install

编译出现的问题
问题1:未定义closesocket,解决办法为在libavutil/timer.h中手动定义 #define closesocket(fd) close(fd)

libavformat/network.c: In function ‘ff_listen_bind’:
libavformat/network.c:254:5: error: implicit declaration of function ‘closesocket’; did you mean ‘ff_socket’? [-Werror=implicit-function-declaration]
     closesocket(fd);
     ^~~~~~~~~~~
     ff_socket
libavformat/options.c: In function ‘format_child_class_next’:
声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
红包 点赞 收藏 评论 打赏
评论
0个
内容存在敏感词
手气红包
    易百纳技术社区暂无数据
相关专栏
置顶时间设置
结束时间
删除原因
  • 广告/SPAM
  • 恶意灌水
  • 违规内容
  • 文不对题
  • 重复发帖
打赏作者
易百纳技术社区
Keith_Cheung
您的支持将鼓励我继续创作!
打赏金额:
¥1易百纳技术社区
¥5易百纳技术社区
¥10易百纳技术社区
¥50易百纳技术社区
¥100易百纳技术社区
支付方式:
微信支付
支付宝支付
易百纳技术社区微信支付
易百纳技术社区
打赏成功!

感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~

举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

审核成功

发布时间设置
发布时间:
是否关联周任务-专栏模块

审核失败

失败原因
备注
拼手气红包 红包规则
祝福语
恭喜发财,大吉大利!
红包金额
红包最小金额不能低于5元
红包数量
红包数量范围10~50个
余额支付
当前余额:
可前往问答、专栏板块获取收益 去获取
取 消 确 定

小包子的红包

恭喜发财,大吉大利

已领取20/40,共1.6元 红包规则

    易百纳技术社区