一、环境概述
主机环境: Ubuntu 18.04 64位 PC平台
目标环境: RK3399(Ubuntu 18.04 64位 ARM平台)
二、准备工作
2.1 首先下载ffmpeg和x264的源代码。如果不知道如何下载,请参考以下链接:https://www.php.cn/link/c98a3fedd72195a304fba80ebaa320fe
2.2 下载并安装aarch64-linux-gcc编译工具,下载地址如下:https://www.php.cn/link/fb739f78a1b83ccad7886436e3146c77
三、开始交叉编译
3.1 交叉编译x264
首先,解压x264源码并进入解压目录:
wbyq@wbyq:~/rk3399$ tar xvf /mnt/hgfs/linux-share-dir/last_x264.tar.bz2wbyq@wbyq:~/rk3399$ cd x264-snapshot-20181217-2245/
然后,配置x264编译选项:
wbyq@wbyq:~/rk3399/x264-snapshot-20181217-2245$ ./configure --prefix=$PWD/_install --disable-asm --enable-shared --enable-static --host=aarch64-linux
配置完成后,config.mak文件将在当前目录生成。请打开并编辑config.mak文件。

继续编译并安装x264:
wbyq@wbyq:~/rk3399/x264-snapshot-20181217-2245$ make && make install
最终生成的文件如下所示:

3.2 交叉编译ffmpeg
首先,解压ffmpeg源码并进入解压目录:
wbyq@wbyq:~/rk3399$ tar xvf /mnt/hgfs/linux-share-dir/ffmpeg-4.2.2.tar.bz2wbyq@wbyq:~/rk3399$ cd ffmpeg-4.2.2/
然后,配置ffmpeg编译选项,注意将x264路径替换为实际路径:
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
最后,编译并安装ffmpeg:
wbyq@wbyq:~/rk3399/ffmpeg-4.2.2$ make && make install
编译生成的文件如下:
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.318 directories, 208 fileswbyq@wbyq:~/rk3399/ffmpeg-4.2.2$
完成上述步骤后,只需将生成的库打包并复制到目标平台即可。
以上就是ubuntu下交叉编译X264和FFMPEG到RK3399平台(编译器:aarch64-linux-gcc)的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/15625.html
微信扫一扫
支付宝扫一扫