gstreamer 在QT中环境开发配置

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


前言

基于ubuntu下QT中的gstreamer开发环境搭建。


提示:以下是本篇文章正文内容,下面案例可供参考

一、安装gstreamer相关开发库

sudo apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio

sudo apt-get install libgstreamer-plugins-base1.0-dev
sudo apt-get install glib-2.0

二、安装好相关库后,使用下列命令,测试模板图像能否正常显示,(注:有些设备可能使用glimagesink 、autovideosink等其它方式显示图像)

gst-launch-1.0 videotestsrc ! ximagesink

三、QT中gstreamer工程配置测试,打印gstreamer的版本信息。

1.pro文件,其中包含了ARM平台的配置,默认是X86平台下的配置

INCLUDEPATH +=  /usr/include/glib-2.0 \
                 /usr/include/gstreamer-1.0

contains(DEFINES, BUILD_ARM_NVIDIA) {
    INCLUDEPATH += /usr/lib/aarch64-linux-gnu/glib-2.0/include \
                   /usr/aarch64-linux-gnu/gstreamer-1.0/include

    LIBS += -L/usr/lib/aarch64-linux-gnu/gstreamer-1.0 -lgstautodetect

} else {
    INCLUDEPATH += /usr/lib/x86_64-linux-gnu/glib-2.0/include \
                   /usr/lib/x86-linux-gnu/gstreamer-1.0/include

    LIBS += -L/usr/lib/x86_64-linux-gnu/gstreamer-1.0 -lgstautodetect
}

LIBS += -lglib-2.0 -lgobject-2.0 -lgstreamer-1.0 -lgstvideo-1.0

2. main.cpp文件

#include "gst/gst.h"
#include "gst/video/videooverlay.h"
#include <glib.h>
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    const gchar *nano_str;
    guint major, minor, micro, nano;
    gst_init(&argc, &argv);
    gst_version(&major, &minor, &micro, &nano);
    if(nano == 1) {
        nano_str = "(CVS)";
    } else if(nano == 2) {
        nano_str = "(Prerelease)";
    } else {
        nano_str = "";
    }
    qDebug("This programe is linked against GStreamer %d.%d.%d %s\n", major, minor, micro, nano_str);

    //create main context
    GMainContext *context = g_main_context_new();
    g_main_context_push_thread_default(context);

    MainWindow w;
    w.show();

    return a.exec();
}


总结

如果能正确打印出gstreamer版本信息,说明gstreamer在QT中环境配置成功。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值