opus库下载
http://www.opus-codec.org/
本文下载的是:opus-1.4.tar.gz
普通编译
./configure --prefix=`pwd`/result_gcc
make && make install
交叉编译:
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官网:https://www.xiph.org/
libogg开源地址:https://github.com/xiph/ogg
交叉编译
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
1、交叉编译 opus-1.4
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
交叉编译 opusfile 错误解决:
问题一:./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 报错:
.../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” 指定链接的库文件名
1、交叉编译 opus-1.4
2、交叉编译 libogg-1.3.5
3、交叉编译 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
opusenc test.wav test.opus
命令解释:
opusenc是官方提供的工具,在Ubuntu下可通过apt安装:sudo apt install opus-tools