ubuntu下交叉编译X264和FFMPEG到RK3399平台(编译器:aarch64-linux-gcc)

简介: ubuntu下交叉编译X264和FFMPEG到RK3399平台(编译器:aarch64-linux-gcc)

一、环境介绍

宿主机环境: ubuntu18.04 64位 PC平台


目标环境: RK3399(ubuntu18.04 64位 ARM平台)


编译器: aarch64-linux-gcc


二、准备工作

2.1 先下载好ffmpeg和x264源码。

不会下载的参考这里:https://blog.csdn.net/xiaolong1126626497/article/details/105784088


2.2 下载安装aarch64-linux-gcc编译器

编译器在这里:https://download.csdn.net/download/xiaolong1126626497/12203205


三、开始交叉编译

3.1 交叉编译x264

wbyq@wbyq:~/rk3399$ tar xvf /mnt/hgfs/linux-share-dir/last_x264.tar.bz2 
wbyq@wbyq:~/rk3399$ cd x264-snapshot-20181217-2245/
wbyq@wbyq:~/x264-snapshot-20181217-2245$./configure --prefix=$PWD/_install --disable-asm --enable-shared --enable-static --host=arm-none-linux-gnueabi

配置之后在当前目录会生成config.mak文件,打开config.mak文件进行修改。

image.png

继续编译安装。

wbyq@wbyq:~/rk3399/x264-snapshot-20181217-2245$ make && make instal

最终生成的文件如下:

image.png

3.2 交叉编译ffmpeg

wbyq@wbyq:~/rk3399$ tar xvf /mnt/hgfs/linux-share-dir/ffmpeg-4.2.2.tar.bz2 
wbyq@wbyq:~/rk3399$ cd ffmpeg-4.2.2/
wbyq@wbyq:~/rk3399/ffmpeg-4.2.2$ ./configure --enable-shared --enable-static --prefix=$PWD/_install --cross-prefix=aarch64-linux- --arch=arm64 --target-os=linux --enable-gpl --extra-cflags=-I/home/wbyq/rk3399/x264-snapshot-20181217-2245/_install/include --extra-ldflags=-L/home/wbyq/rk3399/x264-snapshot-20181217-2245/_install/lib --enable-ffmpeg --enable-libx264
wbyq@wbyq:~/rk3399/ffmpeg-4.2.2$ make && make install

注意:以上配置代码里的x264路径要修成成自己的实际路径。

编译生成的文件如下:

wbyq@wbyq:~/rk3399/ffmpeg-4.2.2$ tree _install/
_install/
├── bin
│   ├── ffmpeg
│   └── ffprobe
├── include
│   ├── libavcodec
│   │   ├── ac3_parser.h
│   │   ├── adts_parser.h
│   │   ├── avcodec.h
│   │   ├── avdct.h
│   │   ├── avfft.h
│   │   ├── d3d11va.h
│   │   ├── dirac.h
│   │   ├── dv_profile.h
│   │   ├── dxva2.h
│   │   ├── jni.h
│   │   ├── mediacodec.h
│   │   ├── qsv.h
│   │   ├── vaapi.h
│   │   ├── vdpau.h
│   │   ├── version.h
│   │   ├── videotoolbox.h
│   │   ├── vorbis_parser.h
│   │   └── xvmc.h
│   ├── libavdevice
│   │   ├── avdevice.h
│   │   └── version.h
│   ├── libavfilter
│   │   ├── avfilter.h
│   │   ├── buffersink.h
│   │   ├── buffersrc.h
│   │   └── version.h
│   ├── libavformat
│   │   ├── avformat.h
│   │   ├── avio.h
│   │   └── version.h
│   ├── libavutil
│   │   ├── adler32.h
│   │   ├── aes_ctr.h
│   │   ├── aes.h
│   │   ├── attributes.h
│   │   ├── audio_fifo.h
│   │   ├── avassert.h
│   │   ├── avconfig.h
│   │   ├── avstring.h
│   │   ├── avutil.h
│   │   ├── base64.h
│   │   ├── blowfish.h
│   │   ├── bprint.h
│   │   ├── bswap.h
│   │   ├── buffer.h
│   │   ├── camellia.h
│   │   ├── cast5.h
│   │   ├── channel_layout.h
│   │   ├── common.h
│   │   ├── cpu.h
│   │   ├── crc.h
│   │   ├── des.h
│   │   ├── dict.h
│   │   ├── display.h
│   │   ├── downmix_info.h
│   │   ├── encryption_info.h
│   │   ├── error.h
│   │   ├── eval.h
│   │   ├── ffversion.h
│   │   ├── fifo.h
│   │   ├── file.h
│   │   ├── frame.h
│   │   ├── hash.h
│   │   ├── hdr_dynamic_metadata.h
│   │   ├── hmac.h
│   │   ├── hwcontext_cuda.h
│   │   ├── hwcontext_d3d11va.h
│   │   ├── hwcontext_drm.h
│   │   ├── hwcontext_dxva2.h
│   │   ├── hwcontext.h
│   │   ├── hwcontext_mediacodec.h
│   │   ├── hwcontext_qsv.h
│   │   ├── hwcontext_vaapi.h
│   │   ├── hwcontext_vdpau.h
│   │   ├── hwcontext_videotoolbox.h
│   │   ├── imgutils.h
│   │   ├── intfloat.h
│   │   ├── intreadwrite.h
│   │   ├── lfg.h
│   │   ├── log.h
│   │   ├── lzo.h
│   │   ├── macros.h
│   │   ├── mastering_display_metadata.h
│   │   ├── mathematics.h
│   │   ├── md5.h
│   │   ├── mem.h
│   │   ├── motion_vector.h
│   │   ├── murmur3.h
│   │   ├── opt.h
│   │   ├── parseutils.h
│   │   ├── pixdesc.h
│   │   ├── pixelutils.h
│   │   ├── pixfmt.h
│   │   ├── random_seed.h
│   │   ├── rational.h
│   │   ├── rc4.h
│   │   ├── replaygain.h
│   │   ├── ripemd.h
│   │   ├── samplefmt.h
│   │   ├── sha512.h
│   │   ├── sha.h
│   │   ├── spherical.h
│   │   ├── stereo3d.h
│   │   ├── tea.h
│   │   ├── threadmessage.h
│   │   ├── timecode.h
│   │   ├── time.h
│   │   ├── timestamp.h
│   │   ├── tree.h
│   │   ├── twofish.h
│   │   ├── tx.h
│   │   ├── version.h
│   │   └── xtea.h
│   ├── libpostproc
│   │   ├── postprocess.h
│   │   └── version.h
│   ├── libswresample
│   │   ├── swresample.h
│   │   └── version.h
│   └── libswscale
│       ├── swscale.h
│       └── version.h
├── lib
│   ├── libavcodec.a
│   ├── libavcodec.so -> libavcodec.so.58.54.100
│   ├── libavcodec.so.58 -> libavcodec.so.58.54.100
│   ├── libavcodec.so.58.54.100
│   ├── libavdevice.a
│   ├── libavdevice.so -> libavdevice.so.58.8.100
│   ├── libavdevice.so.58 -> libavdevice.so.58.8.100
│   ├── libavdevice.so.58.8.100
│   ├── libavfilter.a
│   ├── libavfilter.so -> libavfilter.so.7.57.100
│   ├── libavfilter.so.7 -> libavfilter.so.7.57.100
│   ├── libavfilter.so.7.57.100
│   ├── libavformat.a
│   ├── libavformat.so -> libavformat.so.58.29.100
│   ├── libavformat.so.58 -> libavformat.so.58.29.100
│   ├── libavformat.so.58.29.100
│   ├── libavutil.a
│   ├── libavutil.so -> libavutil.so.56.31.100
│   ├── libavutil.so.56 -> libavutil.so.56.31.100
│   ├── libavutil.so.56.31.100
│   ├── libpostproc.a
│   ├── libpostproc.so -> libpostproc.so.55.5.100
│   ├── libpostproc.so.55 -> libpostproc.so.55.5.100
│   ├── libpostproc.so.55.5.100
│   ├── libswresample.a
│   ├── libswresample.so -> libswresample.so.3.5.100
│   ├── libswresample.so.3 -> libswresample.so.3.5.100
│   ├── libswresample.so.3.5.100
│   ├── libswscale.a
│   ├── libswscale.so -> libswscale.so.5.5.100
│   ├── libswscale.so.5 -> libswscale.so.5.5.100
│   ├── libswscale.so.5.5.100
│   └── pkgconfig
│       ├── libavcodec.pc
│       ├── libavdevice.pc
│       ├── libavfilter.pc
│       ├── libavformat.pc
│       ├── libavutil.pc
│       ├── libpostproc.pc
│       ├── libswresample.pc
│       └── libswscale.pc
└── share
    ├── ffmpeg
    │   ├── examples
    │   │   ├── avio_dir_cmd.c
    │   │   ├── avio_reading.c
    │   │   ├── decode_audio.c
    │   │   ├── decode_video.c
    │   │   ├── demuxing_decoding.c
    │   │   ├── encode_audio.c
    │   │   ├── encode_video.c
    │   │   ├── extract_mvs.c
    │   │   ├── filter_audio.c
    │   │   ├── filtering_audio.c
    │   │   ├── filtering_video.c
    │   │   ├── http_multiclient.c
    │   │   ├── hw_decode.c
    │   │   ├── Makefile
    │   │   ├── metadata.c
    │   │   ├── muxing.c
    │   │   ├── qsvdec.c
    │   │   ├── README
    │   │   ├── remuxing.c
    │   │   ├── resampling_audio.c
    │   │   ├── scaling_video.c
    │   │   ├── transcode_aac.c
    │   │   ├── transcoding.c
    │   │   ├── vaapi_encode.c
    │   │   └── vaapi_transcode.c
    │   ├── ffprobe.xsd
    │   ├── libvpx-1080p50_60.ffpreset
    │   ├── libvpx-1080p.ffpreset
    │   ├── libvpx-360p.ffpreset
    │   ├── libvpx-720p50_60.ffpreset
    │   └── libvpx-720p.ffpreset
    └── man
        ├── man1
        │   ├── ffmpeg.1
        │   ├── ffmpeg-all.1
        │   ├── ffmpeg-bitstream-filters.1
        │   ├── ffmpeg-codecs.1
        │   ├── ffmpeg-devices.1
        │   ├── ffmpeg-filters.1
        │   ├── ffmpeg-formats.1
        │   ├── ffmpeg-protocols.1
        │   ├── ffmpeg-resampler.1
        │   ├── ffmpeg-scaler.1
        │   ├── ffmpeg-utils.1
        │   ├── ffprobe.1
        │   └── ffprobe-all.1
        └── man3
            ├── libavcodec.3
            ├── libavdevice.3
            ├── libavfilter.3
            ├── libavformat.3
            ├── libavutil.3
            ├── libswresample.3
            └── libswscale.3
18 directories, 208 files
wbyq@wbyq:~/rk3399/ffmpeg-4.2.2$

接下来,只需要把生成的库打包拷贝到目标平台即可。


目录
相关文章
|
2月前
|
Ubuntu Linux
查看Linux系统架构的命令,查看linux系统是哪种架构:AMD、ARM、x86、x86_64、pcc 或 查看Ubuntu的版本号
查看Linux系统架构的命令,查看linux系统是哪种架构:AMD、ARM、x86、x86_64、pcc 或 查看Ubuntu的版本号
505 3
|
4天前
|
Ubuntu Linux 测试技术
Linux系统之Ubuntu安装cockpit管理工具
【10月更文挑战第13天】Linux系统之Ubuntu安装cockpit管理工具
25 4
Linux系统之Ubuntu安装cockpit管理工具
|
4天前
|
Linux API 开发工具
FFmpeg开发笔记(五十九)Linux编译ijkplayer的Android平台so库
ijkplayer是由B站研发的移动端播放器,基于FFmpeg 3.4,支持Android和iOS。其源码托管于GitHub,截至2024年9月15日,获得了3.24万星标和0.81万分支,尽管已停止更新6年。本文档介绍了如何在Linux环境下编译ijkplayer的so库,以便在较新的开发环境中使用。首先需安装编译工具并调整/tmp分区大小,接着下载并安装Android SDK和NDK,最后下载ijkplayer源码并编译。详细步骤包括环境准备、工具安装及库编译等。更多FFmpeg开发知识可参考相关书籍。
22 0
FFmpeg开发笔记(五十九)Linux编译ijkplayer的Android平台so库
|
9天前
|
Ubuntu Linux 编译器
Linux/Ubuntu下使用VS Code配置C/C++项目环境调用OpenCV
通过以上步骤,您已经成功在Ubuntu系统下的VS Code中配置了C/C++项目环境,并能够调用OpenCV库进行开发。请确保每一步都按照您的系统实际情况进行适当调整。
114 3
|
11天前
|
并行计算 Ubuntu Linux
Ubuntu学习笔记(三):Linux下操作指令大全
Ubuntu学习笔记,介绍了Linux操作系统中常用的命令和操作,如文件管理、系统信息查看、软件安装等。
32 3
|
16天前
|
Ubuntu Linux 网络安全
如何在Ubuntu 22.04或20.04 Linux上安装MobaXterm
虽然直接在Ubuntu 22.04或20.04上安装MobaXterm是不可能的任务,因为它是专为Windows设计的,但Ubuntu系统提供了丰富的原生工具和替代方案,足以满足远程管理、文件传输等需求。如果你对MobaXterm的特定功能有强烈需求,考虑采用Windows子系统或虚拟机方案作为折衷方案,不失为一种可行之道。在追求高效工作流的同时,不妨也探索和熟悉Linux原生工具,它们往往能提供更为无缝的集成体验。
178 0
|
1月前
|
Ubuntu Linux 开发工具
ubuntu linux搭建lvgl
ubuntu linux搭建lvgl
50 6
|
2月前
|
Ubuntu Linux 开发工具
【事件中心 Azure Event Hub】在Linux环境中(Ubuntu)安装Logstash的简易步骤及配置连接到Event Hub
【事件中心 Azure Event Hub】在Linux环境中(Ubuntu)安装Logstash的简易步骤及配置连接到Event Hub
|
2月前
|
机器学习/深度学习 Ubuntu Linux
【机器学习 Azure Machine Learning】使用Aure虚拟机搭建Jupyter notebook环境,为Machine Learning做准备(Ubuntu 18.04,Linux)
【机器学习 Azure Machine Learning】使用Aure虚拟机搭建Jupyter notebook环境,为Machine Learning做准备(Ubuntu 18.04,Linux)
|
10天前
|
并行计算 Ubuntu Linux
Ubuntu学习笔记(五):18.04安装多版本CUDA
这篇博客文章介绍了在Ubuntu 18.04系统上如何安装和切换不同版本的CUDA,以及如何安装不同版本的cuDNN。
60 2