参考博客:http://bbs.eeworld.com.cn/thread-505971-1-1.html
进入需要放置文件的目录git安装ffmpeg:git clone git://source.ffmpeg.org/ffmpeg.git
进入需要放置文件的目录git安装x264:git clone git://git.videolan.org/x264.git
另外ffmpeg中的播放器程序ffplay依赖sdl来显示视频,sdl是一个图形显示库,安装命令:
sudo apt-get install libsdl2-dev
下载完之后,会有两个git工程下载到本地。接下来就可以开工了(注意以下操作均需cd进入各自的目录)。通过执行./configure –help可以查看帮助信息,如果执行configure配置出错的时候,可以查看ffmpeg源码目录下的config.log文件,此文件提供完整的出错信息。configure执行成功后,会打印配置信息表,一目了然。附件提供的配置脚本,就是调用的configure命令,理解了含义之后,很好用。
安装编译x264
进入git下来的x264目录下
- 新建一个文件config_x264_rpi.sh:
config_x264_rpi.sh
- 然后加上一下内容:
#!/bin/sh
# build x264 for raspberrypi
# ---by shawn (shawn.static@gmail.com)
./configure \
--disable-shared --enable-static \
--enable-strip \
--disable-cli
# disable shared(.so) & static(.a) library
# strip binary, optimize for size.
# disable x264 exection binary for speed.
然后输命令
chmod +x config_x264_rpi.sh
./config_x264_rpi.sh
make -j4
sudo make install
安装编译ffmpeg
进入git下来的ffmpeg目录下
- 新建文件config_ffmpeg_rpi.sh:
vim config_ffmpeg_rpi.sh
- 在文件中加入:
#!/bin/sh
# build ffmpeg for raspberrypi (tested on rpi3)
# v0.1.1-20161129
# --- by shawn (shawn.static@gmail.com)
PREFIX=/usr/local
./configure \
--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-ffserver \
--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-muxer=flv \
--enable-demuxer=flv \
--enable-muxer=mp4 \
--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-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-indev=v4l2 \
--enable-indev=alsa \
\
--enable-omx \
--enable-omx-rpi \
--enable-encoder=h264_omx \
\
--enable-mmal \
--enable-hwaccel=h264_mmal \
--enable-decoder=h264_mmal \
\
#--enable-libx264 \
#--enable-encoder=libx264 \
#
#--enable-decoder=h264 \
#
#--enable-mmal \
#--enable-hwaccel=h264_mmal \
#--enable-decoder=*_mmal \
#
#--enable-omx \
#--enable-omx-rpi \
#--enable-encoder=*_omx \
#
# --enable-mmal, broadcomm multi media abstract layer via mmal for rpi
然后输入命令:
chmod +x config_ffmpeg_rpi.sh
./config_ffmpeg_rpi.sh
make -j4
sudo make install