当前位置:网站首页>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
- Anr principle and Practice
- Détailler le bleu dans les tâches de traduction automatique
- 大咖云集|NextArch基金会云开发Meetup来啦
- Can 7-day zero foundation prove HCIA? Huawei certification system learning path sharing
- Academic report series (VI) - autonomous driving on the journey to full autonomy
- Jesd204b clock network
- Stack Title: nesting depth of valid parentheses
- 2018 Jiangsu Vocational College skills competition vocational group "information security management and evaluation" competition assignment
- How does an enterprise manage data? Share the experience summary of four aspects of data governance
猜你喜欢
组件的嵌套和拆分
Matlab tips (29) polynomial fitting plotfit
Precise space-time travel flow regulation system - ultra-high precision positioning system based on UWB
Flexible layout (I)
虚拟机的作用
Abnova circulating tumor DNA whole blood isolation, genomic DNA extraction and analysis
Release notes of JMeter version 5.5
非父子组件的通信
From zero to one, I will teach you to build the "clip search by text" search service (2): 5 minutes to realize the prototype
[noi simulation] regional division (conclusion, structure)
随机推荐
异步组件和Suspense(真实开发中)
AVL树的实现
Freeswitch dials extension number source code tracking
【JDBC以及内部类的讲解】
詳解機器翻譯任務中的BLEU
Four goals for the construction of intelligent safety risk management and control platform for hazardous chemical enterprises in Chemical Industry Park
A slow SQL drags the whole system down
弹性布局(一)
Basic introduction of JWT
Multidisciplinary integration
Flexible layout (I)
At the age of 20, I got the ByteDance offer on four sides, and I still can't believe it
Multithreading and high concurrency (9) -- other synchronization components of AQS (semaphore, reentrantreadwritelock, exchanger)
leetcode 509. Fibonacci number
Leetcode t1165: log analysis
How to model and simulate the target robot [mathematical / control significance]
LC 面试题 02.07. 链表相交 & LC142. 环形链表II
After the promotion, sales volume and flow are both. Is it really easy to relax?
Paranoid unqualified company
JDBC database connection pool usage problem