当前位置:网站首页>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
边栏推荐
- LC 面试题 02.07. 链表相交 & LC142. 环形链表II
- Release notes of JMeter version 5.5
- .net core 访问不常见的静态文件类型(MIME 类型)
- PostgreSQL source code (59) analysis of transaction ID allocation and overflow judgment methods
- freeswitch拨打分机号源代码跟踪
- 抽丝剥茧C语言(高阶)指针的进阶
- MySQL view bin log and recover data
- linux系统rpm方式安装的mysql启动失败
- 软件验收测试
- Common function detect_ image/predict
猜你喜欢

From zero to one, I will teach you to build the "clip search by text" search service (2): 5 minutes to realize the prototype

Anr principle and Practice

Use of completable future

Le Service MySQL manque dans le service informatique

Nesting and splitting of components

Jesd204b clock network

计算机服务中缺失MySQL服务

IP address

MySQL service is missing from computer service

This article introduces you to the characteristics, purposes and basic function examples of static routing
随机推荐
Non empty verification of collection in SQL
Multithreading and high concurrency (9) -- other synchronization components of AQS (semaphore, reentrantreadwritelock, exchanger)
from . onnxruntime_ pybind11_ State Import * noqa ddddocr operation error
SQLMAP使用教程(四)实战技巧三之绕过防火墙
Détailler le bleu dans les tâches de traduction automatique
异步组件和Suspense(真实开发中)
Please ask a question, flick Oracle CDC, read a table without update operation, and repeatedly read the full amount of data every ten seconds
詳解機器翻譯任務中的BLEU
The startup of MySQL installed in RPM mode of Linux system failed
"Xiaodeng in operation and maintenance" meets the compliance requirements of gdpr
Common function detect_ image/predict
弹性布局(一)
【mysqld】Can't create/write to file
PostgreSQL source code (59) analysis of transaction ID allocation and overflow judgment methods
Esxi attaching mobile (Mechanical) hard disk detailed tutorial
How can flinksql calculate the difference between a field before and after update when docking with CDC?
transform-origin属性详解
Circulating tumor cells - here comes abnova's solution
Network foundation - header, encapsulation and unpacking
Software acceptance test