Created
June 10, 2020 08:37
-
-
Save cxjava/ad5da37f9052ed5465fb7464549fe869 to your computer and use it in GitHub Desktop.
树莓派FFmpeg硬件加速 from https://holmesian.org/Raspberry-Pi-optimized-FFmpeg-with-HW-Acceleration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment