QtQuick使用MediaPlayer抓取摄像头影响报错Error: "Your GStreamer installation is missing a plug-in."

环境:ubuntu18.04 Qt5.9.5

描述:项目需要使用qtquick作为显示界面用于播放从网络摄像头抓取的影像,海康网络摄像头,摄像头源协议使用的是rtsp,影像数据格式为x-h264,但在调试时报错。

 Item{
        MediaPlayer{
            id: player
            source: "rtsp://admin:gene123456@192.168.10.64:554/h264/ch1/main/av_stream"
            autoPlay: true
        }
        VideoOutput{
            anchors.centerIn: parent
            source: player
        }
    }

报错

Starting /home/liang/study/13/03/build-Camera-unknown-Debug/Camera...
Warning: "No decoder available for type 'video/x-h264, stream-format=(string)avc, alignment=(string)au, codec_data=(buffer)014d002affe10018674d002a963540f0044fcb37010101400001c2000057e40101000468ee3c80, level=(string)4.2, profile=(string)main, width=(int)1920, height=(int)1080, framerate=(fraction)25/1, interlace-mode=(string)progressive, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true'."
Error: "Your GStreamer installation is missing a plug-in."
/home/liang/study/13/03/build-Camera-unknown-Debug/Camera exited with code 0

可以看出缺乏适配x-h264格式的解码器,报错缺少GStreamer插件,我在网上查找了很多资料不过很多都是基于ubuntu 14或者ubuntu 16平台下的,但解决方法不尽相同。一下便是我的解决方法

sudo add-apt-repository ppa:mc3man/gstffmpeg-keep

sudo apt-get update

sudo apt-get install gstreamer1.0-libav

sudo apt-get install gstreamer1.0-plugins-bad

sudo apt-get install gstreamer1.0-plugins-good

sudo apt-get install gstreamer1.0-plugins-base

sudo apt-get install gstreamer1.0-plugins-ugly

sudo apt-get install gstreamer1.0-qt5

sudo apt-get install gstreamer1.0-rtsp

原文地址:https://www.cnblogs.com/ohsolong/p/10651923.html