当前位置:网站首页>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
边栏推荐
- Answer to the second stage of the assignment of "information security management and evaluation" of the higher vocational group of the 2018 Jiangsu Vocational College skills competition
- Tumor immunotherapy research prosci Lag3 antibody solution
- 2018 Jiangsu Vocational College skills competition vocational group "information security management and evaluation" competition assignment
- A slow SQL drags the whole system down
- How DHCP router works
- 关于数据库数据转移的问题,求各位解答下
- $refs: get the element object or sub component instance in the component:
- $parent(获取父组件) 和 $root(获取根组件)
- How to do sports training in venues?
- toRefs API 与 toRef Api
猜你喜欢
About binary cannot express decimals accurately
$refs: get the element object or sub component instance in the component:
main函数在import语句中的特殊行为
LC 面试题 02.07. 链表相交 & LC142. 环形链表II
Big coffee gathering | nextarch foundation cloud development meetup is coming
From zero to one, I will teach you to build the "clip search by text" search service (2): 5 minutes to realize the prototype
虚拟机的作用
Special behavior of main function in import statement
Matlab tips (30) nonlinear fitting lsqcurefit
. Net core accesses uncommon static file types (MIME types)
随机推荐
How to model and simulate the target robot [mathematical / control significance]
父组件传递给子组件:Props
弹性布局(一)
Unity C function notes
抽丝剥茧C语言(高阶)指针的进阶
Le Service MySQL manque dans le service informatique
SQLMAP使用教程(四)实战技巧三之绕过防火墙
How can flinksql calculate the difference between a field before and after update when docking with CDC?
After the promotion, sales volume and flow are both. Is it really easy to relax?
from . onnxruntime_ pybind11_ State Import * noqa ddddocr operation error
How can clothing stores make profits?
组件的嵌套和拆分
Modify the jupyter notebook file path
LC 面试题 02.07. 链表相交 & LC142. 环形链表II
Multidisciplinary integration
ViewModelProvider. Of obsolete solution
Sword finger offer high quality code
Jetpack compose is much more than a UI framework~
异步组件和Suspense(真实开发中)
oracle如何备份索引