当前位置:网站首页>MIPS uclibc cross compile ffmpeg, support g711a encoding and decoding
MIPS uclibc cross compile ffmpeg, support g711a encoding and decoding
2022-07-07 07:17:00 【xhoufei2010】
1 explain
Use ffmpeg Source code , Cross compile , Support H264 and G711A Coding support
2 Environmental statement
Hardware environment : mips Architecture chip
Software environment : Linux Any version
3 principle
(1) download ffmpeg Source code , Download from official website
(2) Modify source code , Add to G711A (PCM_ALAW) Support
(3) Use cross compilation , Yes ffmpeg tailoring , In the final control 2M within
4 Operation steps
4.1 download ffmpeg Source code
from ffmpeg Download the source package on the official website , Address the following :
https://ffmpeg.org/download.html#releases
I use ffmpeg-4.4.2 edition
https://ffmpeg.org/releases/ffmpeg-4.4.2.tar.xz
4.2 Modify source code , increase uclibc Support for , solve sys/auxv.h: No such file or directory
If you compile directly , It will give you an error
libavutil/mips/cpu.c:26:22: fatal error: sys/auxv.h: No such file or directory
Please refer to the following patch for modification :
diff --git a/libavutil/mips/cpu.c b/libavutil/mips/cpu.c
index 59619d54de..c5da77b22b 100644
--- a/libavutil/mips/cpu.c
+++ b/libavutil/mips/cpu.c
@@ -19,7 +19,8 @@
#include "libavutil/cpu.h"
#include "libavutil/cpu_internal.h"
#include "config.h"
-#if defined __linux__ || defined __ANDROID__
+#include <features.h>
+#if (defined __linux__ || defined __ANDROID__) && !defined(__UCLIBC__)
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@@ -28,7 +29,7 @@
#include "libavutil/avstring.h"
#endif
-#if defined __linux__ || defined __ANDROID__
+#if (defined __linux__ || defined __ANDROID__) && !defined(__UCLIBC__)
#define HWCAP_LOONGSON_CPUCFG (1 << 14)
@@ -105,7 +106,7 @@ static int cpu_flags_cpuinfo(void)
int ff_get_cpu_flags_mips(void)
{
-#if defined __linux__ || defined __ANDROID__
+#if (defined __linux__ || defined __ANDROID__) && !defined(__UCLIBC__)
if (cpucfg_available())
return cpu_flags_cpucfg();
else
4.3 increase G711A Format support
modify ffmpeg-4.4.2/libavformat/movenc.c file , Refer to the following patch package for modification , You can also patch directly
This patch is for ffmpeg-4.4.2 edition , For other versions, please refer to code modification to adjust the location of the code
--- ffmpeg-4.4.2/libavformat/movenc.c 2022-04-15 04:13:38.000000000 +0800
+++ ffmpeg-4.4.2_new/libavformat/movenc.c 2022-05-18 02:28:02.335515063 +0800
@@ -1190,12 +1190,18 @@ static int mov_write_audio_tag(AVFormatC
track->par->codec_id == AV_CODEC_ID_ALAC ||
track->par->codec_id == AV_CODEC_ID_OPUS) {
avio_wb16(pb, track->par->channels);
+ } else if (track->par->codec_id == AV_CODEC_ID_PCM_ALAW) {
+ avio_wb16(pb, track->par->channels > 0 ?
+ track->par->channels : 1);
} else {
avio_wb16(pb, 2);
}
if (track->par->codec_id == AV_CODEC_ID_FLAC ||
track->par->codec_id == AV_CODEC_ID_ALAC) {
avio_wb16(pb, track->par->bits_per_raw_sample);
+ } else if (track->par->codec_id == AV_CODEC_ID_PCM_ALAW) {
+ avio_wb16(pb, track->par->bits_per_coded_sample > 0 ?
+ track->par->bits_per_coded_sample : 16);
} else {
avio_wb16(pb, 16);
}
@@ -7208,6 +7214,7 @@ static const AVCodecTag codec_mp4_tags[]
{
AV_CODEC_ID_VP9, MKTAG('v', 'p', '0', '9') },
{
AV_CODEC_ID_AV1, MKTAG('a', 'v', '0', '1') },
{
AV_CODEC_ID_AAC, MKTAG('m', 'p', '4', 'a') },
+ {
AV_CODEC_ID_PCM_ALAW, MKTAG('a', 'l', 'a', 'w') },
{
AV_CODEC_ID_ALAC, MKTAG('a', 'l', 'a', 'c') },
{
AV_CODEC_ID_MP4ALS, MKTAG('m', 'p', '4', 'a') },
{
AV_CODEC_ID_MP3, MKTAG('m', 'p', '4', 'a') },
4.4 Cross compilation , And cut it
./configure \
--prefix=$(pwd)/output \
--enable-cross-compile --arch=mips --target-os=linux \
--cross-prefix=mips-linux-uclibc-gnu- --cc=mips-linux-uclibc-gnu-gcc-5.4.0 \
--disable-everything \
--disable-mipsfpu --disable-yasm \
--disable-autodetect \
--disable-avdevice \
--disable-avfilter \
--disable-msa \
--disable-debug \
--disable-protocols --enable-protocol=file \
--disable-demuxers --enable-demuxer=mov \
--disable-muxers --enable-muxer=mp4 --enable-muxer=mov \
--disable-decoders --enable-decoder=pcm_alaw --enable-decoder=h264 --enable-decoder=mpeg4 \
--disable-encoders --enable-encoder=pcm_s16le \
--disable-bsfs --enable-bsf=h264_mp4toannexb \
--disable-static --enable-shared \
--enable-small
explain :
–prefix=$(pwd)/output Set installation directory
–enable-cross-compile --arch=mips --target-os=linux Configure to mips framework
–cross-prefix=mips-linux-uclibc-gnu- --cc=mips-linux-uclibc-gnu-gcc-5.4.0 Cross compiling tool chain and GCC Compiler settings
–disable-everything Close redundant items , Reduce the size of the compilation Library , This depends on your personal situation
–disable-mipsfpu --disable-yasm close mipsfpu , If you do not close the compilation, an error will be reported
–disable-autodetect close autodetect , Reduce library mention
–disable-avdevice close avdevice, Embedded devices do not need
–disable-avfilter close avfilter, The project does not need
–disable-msa close msa , The project does not need
–disable-debug \ close debug , Reduce volume
–disable-protocols --enable-protocol=file The protocol only supports file protocols , It can support the encapsulation and de encapsulation of files
–disable-demuxers --enable-demuxer=mov Support for mov Separation of format files , My project uses MP4 Format ,demuxers No, MP4 Options , however Mov Format compatible mp4
–disable-muxers --enable-muxer=mp4 --enable-muxer=mov
Support mp4 File merge , Used for packing Mp4 file
–disable-decoders --enable-decoder=pcm_alaw --enable-decoder=h264 --enable-decoder=mpeg4
The decoder only turns on pcm_alaw (g711a) h264 mpeg4 this 3 format
–disable-encoders --enable-encoder=pcm_s16le
The encoder is only on pcm_s16le Format , Because my project needs to resample the audio as PCM 16K, So we need to use encoder
–disable-bsfs --enable-bsf=h264_mp4toannexb
bsfs Turn on h264, be used for h264 File decoding , Mandatory
–disable-static --enable-shared
Make the compilation mode of Dynamic State Library
–enable-small
Make file compilation smaller
After the size of the compiled file library is finally trimmed , Pictured 4-2 Shown :
5 Video format introduction :
Composite file : h264+g711a --> mp4 , among h264 and g711a use mips The hardware encoder of the chip , therefore ffmeg The corresponding encoder is not compiled
decode : mp4—> h264 + pcm, take h264 and pcm decode
Different projects adopt different coding formats , You need to modify the configuration parameters for yourself , If you don't know the configuration parameters , have access to
./configure --help
see
if necessary pcm To g711a, Refer to other blogs , Transcoding
https://blog.csdn.net/jenie/article/details/106298846
边栏推荐
- "Xiaodeng in operation and maintenance" meets the compliance requirements of gdpr
- js小练习----分时提醒问候、表单密码显示隐藏效果、文本框焦点事件、关闭广告
- LC 面试题 02.07. 链表相交 & LC142. 环形链表II
- 弹性布局(一)
- Basic process of network transmission using tcp/ip four layer model
- PostgreSQL source code (60) transaction system summary
- Unity C function notes
- freeswitch拨打分机号源代码跟踪
- 子组件传递给父组件
- . Net core accesses uncommon static file types (MIME types)
猜你喜欢
Abnova immunohistochemical service solution
Implementation of AVL tree
Bus message bus
計算機服務中缺失MySQL服務
. Net core accesses uncommon static file types (MIME types)
计算机服务中缺失MySQL服务
freeswitch拨打分机号源代码跟踪
Bindingexception exception (error reporting) processing
Anr principle and Practice
FPGA course: application scenario of jesd204b (dry goods sharing)
随机推荐
FPGA course: application scenario of jesd204b (dry goods sharing)
点亮显示屏的几个重要步骤
Test of transform parameters of impdp
Network foundation - header, encapsulation and unpacking
RuntimeError: CUDA error: CUBLAS_ STATUS_ ALLOC_ Failed when calling `cublascreate (handle) `problem solving
Libcurl returns curlcode description
Mobx knowledge point collection case (quick start)
Get the city according to IP
修改Jupyter Notebook文件路径
Master-slave replication principle of MySQL
oracle如何备份索引
弹性布局(二)
OOM(内存溢出)造成原因及解决方案
异步组件和Suspense(真实开发中)
Multithreading and high concurrency (9) -- other synchronization components of AQS (semaphore, reentrantreadwritelock, exchanger)
虚拟机的作用
MySQL binlog related commands
Role of virtual machine
Please ask a question, flick Oracle CDC, read a table without update operation, and repeatedly read the full amount of data every ten seconds
Flexible layout (II)