This page covers the limitations of the GStreamer backend of Qt Multimedia.
GStreamer is not bundled with Qt, but it is typically deployed with the Linux distribution.
This bug currently affects most mainstream Linux distributions, including Ubuntu 22.04, 23.10 and 24.04, Debian 11 and 12, as well as Fedora 39 and 40.
Qt Multimedia provides certain customization points to allow access to the underlying GStreamer pipeline. These customization points are considered private APIs and may be subject to change. The entry point is
class QGStreamerPlatformSpecificInterface
.
The
GstPipeline
underlying the
QMediaPlayer
and
QMediaCaptureSession
can be accessed.
警告: This is an unsafe API, as the pipeline is still managed by the Qt implementation. Great care is required when using this API.
#include <QtMultimedia/private/qgstreamer_platformspecificinterface_p.h> [...] QMediaMediaPlayer player; GstPipeline *pipeline = QGStreamerPlatformSpecificInterface::instance()->gstPipeline(&player); [...] QMediaCaptureSession session; GstPipeline *pipeline = QGSreamerPlatformSpecificInterface::instance()->gstPipeline(&session);
It is possible to create GStreamer elements from a GStreamer pipeline decription and wrap them inside a
QCamera
or
QAudioDevice
:
#include <QtMultimedia/private/qgstreamer_platformspecificinterface_p.h> [...] QByteArray pipelineString = "videotestsrc is-live=true ! gamma gamma=2.0"; QMediaCaptureSession session; session.setVideoSink(wid.videoSink()); QCamera *cam = QGStreamerPlatformSpecificInterface::instance()->makeCustomGStreamerCamera( pipelineString, &session); session.setCamera(cam);
The
QMediaPlayer
accepts a GStreamer pipeline decription as source URI:
QMediaPlayer player; player.setSource(u"gstreamer-pipeline: videotestsrc name=testsrc"_s);
This will try to compile the pipeline description to use as source in the QMediaPlayer and will be automatically connected to the sinks of the QMediaPlayer .
警告:
Hic sunt dracones! Custom pipelines are an experimental feature: the custom pipelines do not map well to
QMediaPlayer
APIs, most notably the media status, metadata APIs, and transport state. Most calls will directly map to the GStreamer pipeline, which can lead to undefined behavior depending on the pipeline. In most cases, the
gstreamer-pipeline:
may not be the right choice for application code: for arbitrary video sources, the
QMediaCaptureSession
with a custom camera (see above) is the preferred choice. For arbitrarily complex pipelines that only want to draw into a Qt/QML GUI, GStreamer's
qml6glsink
(see below) may be a more robust choice.
Qt Multimedia is not a general purpose streaming framework and not necessarily the architecturally best way to use GStreamer with Qt. Developers, who need a high degree of control over the GStreamer pipeline, but only want to show the video output Qt, may want to consider using GStreamer's qml6glsink .