一、环境介绍
宿主机环境: 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文件进行修改。
继续编译安装。
wbyq@wbyq:~/rk3399/x264-snapshot-20181217-2245$ make && make instal
最终生成的文件如下:
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
编译生成的文件如下:
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 files
wbyq@wbyq:~/rk3399/ffmpeg-4.2.2$