树莓派之部署QT与FFmpeg硬解开发环境

// 安装 QT
sudo apt-get update
sudo apt-get install qt5-default
sudo apt-get install qtcreator
sudo apt-get install qtdeclarative5-dev // QML
// 需要自己手动配置构建套件,配置qmake,gcc,g++,gdb

FFmpeg 编译 及 支持 x264 …

// 安装 GIT
sudo apt-get update
sudo apt-get install git

// 创建 config_x264_rpi.sh
#!/bin/sh
./configure \
--enable-shared \
--enable-static \
--enable-strip \
--disable-cli

git clone git://git.videolan.org/x264.git
cd x264
mv ../config_x264_rpi.sh ./
chmod +x config_x264_rpi.sh
./config_x264_rpi.sh
make -j4
sudo make install
// 测试
./configure --prefix=/usr/local --enable-shared --disable-static --enable-strip --disable-cli
// 下载 http://ffmpeg.org/releases/ -> 3.4.4
sudo apt-get install libomxil-bellagio-dev 

// 解压后进入 ffmepg 目录 ...
// 创建 config_ffmepg_rpi.sh
#!/bin/sh
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-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-omx \
--enable-omx-rpi \
--enable-encoder=h264_omx \
\
--enable-mmal \
--enable-hwaccel=h264_mmal \
--enable-decoder=h264_mmal \
\

// 编译 ..
chmod +x config_ffmpeg_rpi.sh
./config_ffmpeg_rpi.sh
make -j4
sudo make install

// 输入ffmpeg并回车其中有h264_omx和h264_mmal字样
// 说明ffmpeg已支持树莓派的H.264硬件编解码器。
// 补充:如果需要 avformat_open_input .264 格式流需要增加
--enable-demuxer=h264
--enable-demuxer=aac // open input aac
// 测试
./configure --prefix=/usr/local --enable-version3 --enable-nonfree --enable-gpl --disable-static --enable-shared --enable-libx264 --enable-encoder=libx264 --enable-decoder=h264 --enable-encoder=aac --enable-decoder=aac --enable-omx --enable-omx-rpi --enable-encoder=h264_omx --enable-mmal --enable-hwaccel=h264_mmal --enable-decoder=h264_mmal 
// FFmpeg License and Legal Considerations
./configure --prefix=/usr/local --enable-version3 --disable-static --enable-shared --enable-decoder=h264 --enable-encoder=aac --enable-decoder=aac --enable-omx --enable-omx-rpi --enable-encoder=h264_omx --enable-mmal --enable-hwaccel=h264_mmal --enable-decoder=h264_mmal
// 引用 FFmepg 库 -> xxx.pro
LIBS+=-L/usr/local/lib -lavformat -lavcodec -lavutil -lx264 
LIBS+=-lpthread -lm -ldl -lfreetype -lz 
LIBS+=-L/opt/vc/lib -lmmal_core -lmmal_util -lmmal_vc_client -lbcm_host 
INCLUDEPATH+=/usr/local/include 
// 测试
extern "C"
{
    #include "libavcodec/avcodec.h"
    #include "libavformat/avformat.h"
    #include "libswscale/swscale.h"
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    qDebug() << avcodec_configuration();
    return a.exec();
}

https://github.com/popcornmix/FFmpeg/tree/2711

RPI_TOOLROOT=/usr
RPI_OPT_VC=/opt/vc

RPI_INCLUDES="-I$RPI_OPT_VC/include -I$RPI_OPT_VC/include/interface/vcos/pthreads -I$RPI_OPT_VC/include/interface/vmcs_host/linux"
RPI_DEFS="-D__VCCOREVER__=0x04000000 -DRPI_DISPLAY=1"
RPI_LIBDIRS="-L$RPI_TOOLROOT/lib -L$RPI_OPT_VC/lib"
#RPI_KEEPS="-save-temps=obj"
RPI_KEEPS=""

./configure --enable-cross-compile\
 --arch=armv6t2\
 --cpu=cortex-a7\
 --target-os=linux\
 --disable-stripping\
 --disable-thumb\
 --enable-mmal\
 --enable-rpi\
 --extra-cflags="-g $RPI_KEEPS $RPI_DEFS $RPI_INCLUDES"\
 --extra-cxxflags="$RPI_DEFS $RPI_INCLUDES"\
 --extra-ldflags="$RPI_LIBDIRS -Wl,-rpath=/opt/vc/lib,-rpath-link=$RPI_OPT_VC/lib,-rpath=/lib,-rpath=/usr/lib,-rpath-link=$RPI_TOOLROOT/lib,-rpath-link=$RPI_TOOLROOT/lib"\
 --extra-libs="-Wl,--start-group -lbcm_host -lmmal -lmmal_util -lmmal_core -lvcos -lvcsm -lvchostif -lvchiq_arm"\
 --cross-prefix=$RPI_TOOLROOT/bin/arm-linux-gnueabihf- \
 --prefix=/usr/local \
 --extra-libs="-ldl"