下载直通车:我用的是6.0版本的
![](https://file.jishuzhan.net/article/1693488742997692418/7d2f23559bae4a33af48137e4944e63b.png)
1.准备编译:
![](https://file.jishuzhan.net/article/1693488742997692418/d5c65a96524b4668be270f384e1eb4fb.png)
2.进入ffmpeg源码目录,修改Makefile,添加编译选项:
CFLAGS += -fPIC
不加会报错
![](https://file.jishuzhan.net/article/1693488742997692418/c9e76effb44d4c5391a8405b8ee330fe.png)
![](https://file.jishuzhan.net/article/1693488742997692418/529a672aed9f453c9b4c6cc42e84cc94.png)
3.使用命令直接编译
./configure --cross-prefix=/home/xxx/bin/arm-linux-gnueabihf- --enable-cross-compile --target-os=linux --cc=/home/xxx/bin/arm-linux-gnueabihf-gcc --arch=arm --prefix=$PWD/_install --enable-shared --disable-static --enable-gpl --enable-nonfree --disable-ffplay --enable-swscale --enable-pthreads --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-x86asm --disable-stripping --enable-libx264 --extra-cflags=-I/home/xxx/x264-master/_install/include --extra-ldflags=-L/home/xxx/x264-master/_install/lib --extra-libs=-ldl --pkg-config="pkg-config --static"
注意这里需要把--cross-prefix=与--cc=还有x264的--extra-cflags=与 --extra-ldflags=改成你们自己的地址
额外补充一点:如果你的arm架构是64的话,需要把 **--arch=arm改为--arch=arm64**
会报错:ERROR: x264 not found using pkg-config
我的情况下的解决方式:配置一下地址
export PKG_CONFIG_PATH="/home/xxx/x264-master/_install/lib/pkgconfig"
然后再运行上面第三步的命令
![](https://file.jishuzhan.net/article/1693488742997692418/7d65f89e594f4283a30fc8fdba8e7b14.png)
4.直接make等待编译完成
![](https://file.jishuzhan.net/article/1693488742997692418/ec85aace06c646a0835e454f8c252cb2.png)
![](https://file.jishuzhan.net/article/1693488742997692418/5fb81399ce284192909fdfac6e655736.png)
5:make install 以后我们就可以在_install目录看到对应文件了