【音视频 | opus】opus编译全过程

😁博客主页😁:🚀https://blog.csdn.net/wkd_007🚀
🤑博客内容🤑:🍭嵌入式开发、Linux、C语言、C++、数据结构、音视频🍭
🤣本文内容🤣:🍭介绍音频编码opus的相关开源库编译🍭
😎金句分享😎:🍭子曰:古者言之不出,耻躬之不逮也。 ——《论语·里仁篇》,意思是,古代的君子从不轻易发表言论,他们以说了二做不到为耻。🍭


在这里插入图片描述

🎄一、opus-1.4

✨1.1 opus库下载

http://www.opus-codec.org/

本文下载的是:opus-1.4.tar.gz

✨1.2 opus库普通编译

./configure --prefix=`pwd`/result_gcc
make && make install

✨1.3 opus库交叉编译

交叉编译:

tar zxvf opus-1.4.tar.gz
cd opus-1.4/
./configure --prefix=`pwd`/result_v300 CC=arm-hisiv300-linux-gcc --host=arm-hisiv300-linux
make && make install

运行demo:

opus_demo 在 opus-1.4/.libs/ 文件夹里

#opus编码 
# ./opus_demo -e audio 48000 2 64000 48000Hz-16bit-2ch-ChengDu.pcm 48000Hz-16bit-2ch-ChengDu.opus
libopus 1.4
Encoding 48000 Hz input at 64.000 kb/s in auto bandwidth with 960-sample frames.
average bitrate:              57.447 kb/s
maximum bitrate:             127.600 kb/s
active bitrate:               57.470 kb/s
bitrate standard deviation:    8.813 kb/s


#opus解码
# ./opus_demo -d 48000 2 48000Hz-16bit-2ch-ChengDu.opus  48000Hz-16bit-2ch-ChengDu1.pcm
libopus 1.4
Decoding with 48000 Hz output (2 channels)
average bitrate:              57.447 kb/s
maximum bitrate:             127.600 kb/s
bitrate standard deviation:    8.813 kb/s

在这里插入图片描述

🎄二、libogg-1.3.5

✨2.1 libogg-1.3.5 库下载

libogg官网:https://www.xiph.org/

libogg开源地址:https://github.com/xiph/ogg

✨2.2 libogg-1.3.5 库交叉编译

tar zxvf libogg-1.3.5.tar.gz
cd libogg-1.3.5/
./configure --prefix=`pwd`/result_v300 CC=arm-hisiv300-linux-gcc --host=arm-hisiv300-linux
make && make install

在这里插入图片描述

🎄三、opusfile-0.12

✨3.1 opusfile-0.12 库下载

opusfile-0.12 库下载地址:https://www.opus-codec.org/downloads/

在这里插入图片描述

✨2.2 opusfile-0.12 库交叉编译

首先,需要编译依赖库:opus-1.4、libogg-1.3.5、openssl-1.1.0g

1、交叉编译 opus-1.4,参见上文 1.3 opus库交叉编译

2、交叉编译 libogg-1.3.5,参见上文 2.2 libogg-1.3.5 库交叉编译

3、交叉编译 openssl-1.1.0g

tar zxf openssl-1.1.0g.tar.gz
cd openssl-1.1.0g/
./config no-asm shared no-async --prefix=`pwd`/result_v300  --cross-compile-prefix=arm-hisiv300-linux-

# 删除 -m64
sed -i 's/-m64//' Makefile

#添加 CFLAGS+=-mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4 -mno-unaligned-access -fno-aggressive-loop-optimizations
sed -i '/CFLAGS=-DDSO_DLFCN/a\CFLAGS+=-mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4 -mno-unaligned-access -fno-aggressive-loop-optimizations' Makefile

make && make install

4、交叉编译opusfile-0.12:

tar zxvf opusfile-0.12.tar.gz 
cd opusfile-0.12/

# DEPS_CFLAGS、DEPS_LIBS指定依赖库libogg的路径,否则会报错
./configure --prefix=`pwd`/result_v300 CC=arm-hisiv300-linux-gcc --host=arm-hisiv300-linux DEPS_CFLAGS="-I`pwd`/../libogg-1.3.5/result_v300/include/" DEPS_LIBS="`pwd`/../libogg-1.3.5/result_v300/lib/" CFLAGS="-I`pwd`/../libogg-1.3.5/result_v300/include/ -L`pwd`/../libogg-1.3.5/result_v300/lib/ -I`pwd`/../opus-1.4/result_v300/include/opus -L`pwd`/../opus-1.4/result_v300/lib/ -I`pwd`/../openssl-1.1.0g/result_v300/include/ -L`pwd`/../openssl-1.1.0g/result_v300/lib/ -lssl -lcrypto -lopus -logg"

make && make install

✨2.2 opusfile-0.12 库交叉编译问题解决

问题一:./configure 报错

./configure 报错:

configure: error: Package requirements (ogg >= 1.3 opus >= 1.0.1) were not met:

No package 'ogg' found
No package 'opus' found

原因:检测依赖库时,没有找到依赖的库 ogg、opus;

解决:通过DEPS_CFLAGS、DEPS_LIBS指定依赖的ogg头文件、ogg库文件。

问题二:make 报错

make 报错:

.../bin/ld: warning: libssl.so.1.1, needed by ./.libs/libopusurl.so, not found (try using -rpath or -rpath-link)
.../bin/ld: warning: libcrypto.so.1.1, needed by ./.libs/libopusurl.so, not found (try using -rpath or -rpath-link)
collect2: error: ld returned 1 exit status

原因:链接时,没找到 libssl.so.1.1、libcrypto.so.1.1

解决:通过 CFLAGS=“-lssl -lcrypto” 指定链接的库文件名

在这里插入图片描述

🎄四、opus-tools-0.2

✨4.1 opus-tools-0.2相关库下载

opus-tools-0.2相关库:libopusenc-0.2.1opus-tools-0.2.tar.gz

下载地址:https://www.opus-codec.org/downloads/

在这里插入图片描述

✨4.2 opus-tools-0.2库交叉编译

1、交叉编译 opus-1.4,参见上文 1.3 opus库交叉编译

2、交叉编译 libogg-1.3.5,参见上文 2.2 libogg-1.3.5 库交叉编译

3、交叉编译 opusfile-0.12,参见上文 2.2 opusfile-0.12 库交叉编译

4、交叉编译 libopusenc-0.2.1

tar zxf libopusenc-0.2.1.tar.gz 
cd libopusenc-0.2.1/  
./configure --prefix=`pwd`/result_v300 CC=arm-hisiv300-linux-gcc --host=arm-hisiv300-linux DEPS_CFLAGS="-I`pwd`/../opus-1.4/result_v300/include/" DEPS_LIBS="-L`pwd`/../opus-1.4/result_v300/lib/" CFLAGS="-I`pwd`/../opus-1.4/result_v300/include/opus -L`pwd`/../opus-1.4/result_v300/lib/ -lopus"
make && make install

问题:make报错

/home/samba/00_thirdLib/001_opus/libopusenc-0.2.1/../opus-1.4/result_v300/include/: file not recognized: Is a directory
collect2: error: ld returned 1 exit status

原因:DEPS_CFLAGS指定路径时,没加-I


5、交叉编译

下载:https://xiph.org/flac/

tar xf flac-1.4.3.tar.xz 
cd flac-1.4.3/
./configure --prefix=`pwd`/result_v300 CC=arm-hisiv300-linux-gcc --host=arm-hisiv300-linux CFLAGS="-I`pwd`/../libogg-1.3.5/result_v300/include/ -L`pwd`/../libogg-1.3.5/result_v300/lib/ -logg"

6、交叉编译:opus-tools-0.2

tar zxvf opus-tools-0.2.tar.gz
cd opus-tools-0.2/

./configure --prefix=`pwd`/result_v300 CC=arm-hisiv300-linux-gcc --host=arm-hisiv300-linux OGG_CFLAGS="-I`pwd`/../libogg-1.3.5/result_v300/include/" OGG_LIBS="-L`pwd`/../libogg-1.3.5/result_v300/lib/  -logg" OPUS_CFLAGS="-I`pwd`/../opus-1.4/result_v300/include/opus" OPUS_LIBS="-L`pwd`/../opus-1.4/result_v300/lib/  -lopus" OPUSFILE_CFLAGS="-I`pwd`/../opusfile-0.12/result_v300/include/opus" OPUSFILE_LIBS="-L`pwd`/../opusfile-0.12/result_v300/lib/ -lopusfile" OPUSURL_CFLAGS="-I`pwd`/../opusfile-0.12/result_v300/include/" OPUSURL_LIBS="-L`pwd`/../opusfile-0.12/result_v300/lib/ -lopusurl" LIBOPUSENC_CFLAGS="-I`pwd`/../libopusenc-0.2.1/result_v300/include/opus" LIBOPUSENC_LIBS="-L`pwd`/../libopusenc-0.2.1/result_v300/lib/ -lopusenc" FLAC_CFLAGS="-I`pwd`/../flac-1.4.3/result_v300/include/" FLAC_LIBS="-L`pwd`/../flac-1.4.3/result_v300/lib/ -lFLAC" 

CFLAGS="-I`pwd`/../libogg-1.3.5/result_v300/include/ -L`pwd`/../libogg-1.3.5/result_v300/lib/ -logg -I`pwd`/../opus-1.4/result_v300/include/opus -L`pwd`/../opus-1.4/result_v300/lib/ -logg -I`pwd`/../libopusenc-0.2.1/result_v300/include/opus -L`pwd`/../libopusenc-0.2.1/result_v300/lib/"

make && make install

✨4.2 opus-tools-0.2 使用

opus-tool有四个工具:

  • opusdec :将 opus 文件转成 wav 文件
  • opusenc :将 wav 文件转成 opus 文件
  • opusinfo :查看 opus 编码的 ogg 封装格式文件的信息;
  • opusrtp :可以从opus的抓包文件中提取出来opus音频,opusrtp输出的是已经封装到ogg中的音频。

使用下面命令可以将 wav 的音频转成 opus 的:

opusenc test.wav test.opus

下面命令将 opus 的音频转成 wav 的:

opusdec test.opus test.wav 

另外,如果想在Ubuntu使用opusenc 命令,可通过apt安装:sudo apt install opus-tools

在这里插入图片描述

🎄五、总结

本文介绍 opus-1.4、libogg-1.3.5、opusfile-0.12、opus-tools-0.2 的交叉编译过程,以及问题解决。
在这里插入图片描述
如果文章有帮助的话,点赞👍、收藏⭐,支持一波,谢谢 😁😁😁

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wkd_007

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值