树莓派4B硬解码编译安装FFMPEG与X264过程

xingyun86 2021-8-21 1507

树莓派4B硬解码编译安装FFMPEG与X264过程

一、环境介绍

开发板:树莓派4B

二、编译安装X264

下面一切都在树莓派4B上操作,下面步骤里下载各种安装包之后(下载通过树莓派4B自带的谷歌浏览器下载),再将安装包移动到U盘里进行编译的,主要是树莓派4B本身空间不大。

工作路径:/home/pi/source

2.1 编译安装NASM

下载NASM库:  http://distfiles.macports.org/nasm/

$wget http://distfiles.macports.org/nasm/nasm-2.15.05.tar.bz2
$tar xvf nasm-2.15.05.tar.bz2
$cd nasm-2.15.05
$./configure
$make && sudo make install

2.2 下载编译SDL2

下载地址: https://www.libsdl.org/download-2.0.php

$wget https://www.libsdl.org/release/SDL2-2.0.16.tar.gz
$tar xvf SDL2-2.0.16.tar.gz
$cd SDL2-2.0.16
$./configure --prefix=$PWD/_install
$make && make install
$sudo cp _install/include /usr/ -rf
$sudo cp _install/lib /usr/ -rf

2.3 下载编译X264

下载地址: https://www.videolan.org/developers/x264.html

$wget https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar.bz2
$tar xvf x264-master.tar.bz2
$cd x264-master
$./configure --prefix=$PWD/_install --enable-shared
$make && make install
$sudo cp _install/include /usr/ -rf
$sudo cp _install/lib /usr/ -rf

2.4 下载编译FFMPEG库

下载地址:  http://www.ffmpeg.org/download.html

$wget http://www.ffmpeg.org/releases/ffmpeg-4.4.tar.bz2
$tar xvf ffmpeg-4.4.tar.bz2
$cd ffmpeg-4.4
$sudo apt-get install libomxil-bellagio-dev
$sudo apt-get install libasound2-dev
保存以下内容为config_ffmpeg.sh, chmod +x ./config_ffmpeg.sh, ./config_ffmpeg.sh运行
====================================================
#!/bin/sh
PREFIX=$PWD/_install
./configure \
--extra-ldflags="-latomic" \
--enable-gpl    --enable-version3 --enable-nonfree \
--enable-static --disable-shared \
\
--prefix=$PREFIX \
\
--disable-opencl \
--disable-thumb \
--disable-pic \
--disable-stripping \
\
--enable-small \
\
--enable-ffmpeg \
--enable-ffplay \
--enable-ffprobe \
\
--disable-doc \
--disable-htmlpages \
--disable-podpages \
--disable-txtpages \
--disable-manpages \
\
--disable-everything \
\
--enable-libx264 \
--enable-encoder=libx264 \
--enable-decoder=h264 \
--enable-encoder=aac \
--enable-decoder=aac \
--enable-encoder=ac3 \
--enable-decoder=ac3 \
--enable-encoder=rawvideo \
--enable-decoder=rawvideo \
--enable-encoder=mjpeg \
--enable-decoder=mjpeg \
\
--enable-demuxer=concat \
--enable-muxer=flv \
--enable-demuxer=flv \
--enable-demuxer=live_flv \
--enable-muxer=hls \
--enable-muxer=segment \
--enable-muxer=stream_segment \
--enable-muxer=mov \
--enable-demuxer=mov \
--enable-muxer=mp4 \
--enable-muxer=mpegts \
--enable-demuxer=mpegts \
--enable-demuxer=mpegvideo \
--enable-muxer=matroska \
--enable-demuxer=matroska \
--enable-muxer=wav \
--enable-demuxer=wav \
--enable-muxer=pcm* \
--enable-demuxer=pcm* \
--enable-muxer=rawvideo \
--enable-demuxer=rawvideo \
--enable-muxer=rtsp \
--enable-demuxer=rtsp \
--enable-muxer=rtsp \
--enable-demuxer=sdp \
--enable-muxer=fifo \
--enable-muxer=tee \
\
--enable-parser=h264 \
--enable-parser=aac \
\
--enable-protocol=file \
--enable-protocol=tcp \
--enable-protocol=rtmp \
--enable-protocol=cache \
--enable-protocol=pipe \
\
--enable-filter=aresample \
--enable-filter=allyuv \
--enable-filter=scale \
--enable-libfreetype \
\
--enable-indev=v4l2 \
--enable-indev=alsa \
--enable-indev=alsa \
--enable-outdev=alsa \
\
--enable-omx \
--enable-omx-rpi \
--enable-encoder=h264_omx \
\
--enable-mmal \
--enable-hwaccel=h264_mmal \
--enable-decoder=h264_mmal \
====================================================
$make && make install
$sudo cp _install/include /usr/ -rf
$sudo cp _install/lib /usr/ -rf
$sudo cp _install/bin /usr/ -rf
$ffmpeg -v

2.4 将库集合到一个目录下,方便后续编译调用,指定路径

$mkdir ffmpeg_x264_SDL2_lib
$cp /home/pi/source/SDL2-2.0.16/_install/* ./ -rf
$cp /home/pi/source/x264-master/_install/* ./ -rf
$cp /home/pi/source/ffmpeg-4.4/_install/* ./ -rf


×
打赏作者
最新回复 (0)
只看楼主
全部楼主
返回