提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
前言
基于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, µ, &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中环境配置成功。