文档

脚本

# Raspberry Pi的GPU对 H264有一系列针对 MPEG4 H264、MPEG2 和 VC1(需要额外授权)的硬件加速优化,为了得到最好的性能,建议先对树莓派的启动设置文件(/boot/config.txt)进行如下的调整:
# gpu_mem=256
# framebuffer_depth=16

# 直接使用 apt-get 安装的ffmpeg没有专门的优化,对硬解的支持不好,所以需要自己从源码编译安装,首先用 apt-get 安装一些必要的包:


apt-get install autoconf automake build-essential libass-dev libfreetype6-dev  libtheora-dev libtool libvorbis-dev pkg-config texinfo zlib1g-dev unzip cmake yasm libx264-dev libmp3lame-dev libopus-dev bzip2-dev

git clone https://code.videolan.org/videolan/x264.git
cd x264/
git checkout 72d53ab2ac7af24597a824e868f2ef363a22f5d4
sudo ./configure --disable-asm --enable-shared --disable-win32thread --enable-strip --extra-cflags='-march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard'
sudo make -j 4 V=1
sudo make install
sudo ldconfig


wget http://libmpeg2.sourceforge.net/files/libmpeg2-0.5.1.tar.gz
tar -xvzpf libmpeg2-0.5.1.tar.gz
cd libmpeg2-0.5.1
./configure --disable-largefile


# 设置完成之后,修改Makefiles文件(可直接用 vi 编辑 libmpeg2-0.5.1 目录下的Makefiles文件),找到 “CFLAGS=” 字段,在末尾添加“ -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard” 然后继续编译安装。

sudo make -j 4 V=1
sudo make install
sudo ldconfig


wget https://github.com/libass/libass/releases/download/0.13.7/libass-0.13.7.tar.gz
tar -xvzpf libass-0.13.7.tar.gz
cd libass-0.13.7/
./configure
sudo make -j 4 V=1
sudo make install
sudo ldconfig
    


git clone --depth 1 https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
export LDFLAGS="-L /opt/vc/lib/"
    
./configure --extra-ldflags="-L /opt/vc/lib/" --extra-cflags='-march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mvectorize-with-neon-quad -mfloat-abi=hard' --extra-cxxflags='-march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mvectorize-with-neon-quad -mfloat-abi=hard' --disable-devices --disable-ffprobe --disable-doc --disable-w32threads --enable-ffplay --extra-libs=-ldl --enable-shared --enable-libass --disable-devices --enable-mmal --enable-decoder=h264_mmal --enable-decoder=mpeg2_mmal --enable-encoder=h264_omx --enable-omx --enable-omx-rpi --enable-neon --enable-gnutls --enable-libvorbis --enable-muxer=ogg --enable-encoder=libvorbis --enable-nonfree --enable-libx264 --enable-gpl --enable-runtime-cpudetect --enable-postproc --enable-muxer=spdif --enable-muxer=adts --enable-muxer=asf --enable-encoder=ac3 --enable-encoder=aac --enable-encoder=wmav2 --enable-protocol=http --enable-encoder=png --enable-encoder=mjpeg  --enable-pthreads --enable-pic --enable-zlib --disable-mipsdsp --disable-mipsdspr2

sudo make -j 4 V=1
sudo make install 
sudo ldconfig

aarch64树莓派

[树莓派]aarch64 系统安装opencv 并使用硬件加速
https://segmentfault.com/a/1190000040089444

[树莓派]aarch64 系统 编译最新的ffmpeg 并支持硬解h264
https://segmentfault.com/a/1190000040086717

[树莓派]aarch64编译静态的ffmpeg 可硬解h264/hevc
https://segmentfault.com/a/1190000040129616