安装mpp
git clone https://ghproxy.com/https://github.com/rockchip-linux/mpp --depth=1
cd mpp
mkdir build
cd build
cmake ..
make && sudo make install
安装 gstreamer-rockchip
git clone https://ghproxy.com/https://github.com/JeffyCN/rockchip_mirrors --branch gstreamer-rockchip --depth=1 gstreamer-rockchip
# 如果没有装meson要先装meson
sudo apt install meson ninja-build
cd gstreamer-rockchip
meson build
cd build
meson configure --prefix=/usr
ninja build
sudo ninja install
这时候gstreamer mpp插件就安装好了
gst-inspect-1.0 --plugin | grep mpp
上面指令应该会有以下输出
rockchipmpp: mpph264enc: Rockchip Mpp H264 Encoder
rockchipmpp: mpph265enc: Rockchip Mpp H265 Encoder
rockchipmpp: mppjpegdec: Rockchip's MPP JPEG image decoder
rockchipmpp: mppjpegenc: Rockchip Mpp JPEG Encoder
rockchipmpp: mppvideodec: Rockchip's MPP video decoder
rockchipmpp: mppvp8enc: Rockchip Mpp VP8 Encoder
rockchipmpp: mppvpxalphadecodebin: VP8/VP9 Alpha Decoder
typefindfunctions: audio/x-musepack: mpc, mpp, mp+
测试一下编码
gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=100 ! video/x-raw, width=640, height=480 ! videoconvert ! queue ! mpph264enc ! h264parse ! mp4mux ! filesink location=video.mp4
这样会生成一个video.mp4文件,可以看到在编码过程中CPU消耗是极小的。如果一切正常就可以用mpv之类的播放器播放这个文件。