Qt Multimedia

"image of multimedia icons, courtesy of misirlou from the Noun Project"

Qt Multimedia is an add-on module that provides a rich set of QML types and C++ classes to handle multimedia content. It contains an easy to use API for playing back audio and video files and rendering those on screen, as well as a comprehensive API for recording audio and video from the systems cameras and microphones.

The functionality of this module is divided into the following submodules:

Qt MultimediaProvides API for multimedia-specific use cases.
Qt Multimedia WidgetsProvides the widget-based multimedia API.

Getting started

If you are porting from Qt 5 to Qt 6 see Changes to Qt Multimedia.

If you are new to Qt Multimedia, the QML types can be imported into an application using the following statement in your .qml file.

 import QtMultimedia

If you want to use the C++ classes in your application, include the C++ definitions using the following directive:

 #include <QtMultimedia>
 #include <QtMultimediaWidgets>

Note: If you are using a few classes from this module, we recommend including those specific classes only instead of the module.

To link against the C++ libraries, add the following to your project's CMakeLists.txt file. Substitute my_project with the name of your project.

 find_package(Qt6 COMPONENTS Multimedia REQUIRED)
 target_link_libraries(my_project PUBLIC Qt::Multimedia)

QML Types

The following table outlines some important QML types.

TypeDescription
MediaPlayerAdd audio/video playback functionality to a scene.
CaptureSessionCreate a session for capturing audio/video.
CameraAccess a camera connected to the system.
AudioInputAccess an audio input (microphone) connected to the system.
AudioOutputAccess an audio output (speaker, headphone) connected to the system.
VideoOutputDisplay video content.
MediaRecorderRecord audio/video from the CaptureSession.
ImageCaptureCapture still images from the Camera.
VideoAdd Video playback functionality to a scene. Uses MediaPlayer and VideoOutput types to provide video playback functionality.

C++ Classes

The following table outlines some important C++ Classes

ClassDescription
QMediaPlayerPlayback media from a source.
QVideoWidgetDisplay video from a media player or a capture session.
QMediaCaptureSessionCapture audio and video.
QCameraAccess a camera connected to the system
QAudioInputAccess an audio input (microphone) connected to the system.
QAudioOutputAccess an audio output (speaker, headphone) connected to the system.
QImageCaptureCapture still images with a camera.
QMediaRecorderRecord media content from a capture session.
QVideoSinkAccess and render individual video frames.
QAudioSinkSends raw audio data to an audio output device.

For playback QMediaPlayer, QAudioOutput and QVideoOutput contain all the required functionality. The other classes are used for capturing audio and video content, where the QMediaCaptureSession is the central class managing the whole capture/recording process.

Licenses and attributions

The Qt Quick Multimedia module is available under commercial licenses from The Qt Company. In addition, it is available under free software licenses. Since Qt 5.6, these free software licenses are GNU Lesser General Public License, version 3, or the GNU General Public License, version 2. See Qt Licensing for further details.

Guides

Platform notes

For most features, Qt Multimedia builds upon the multimedia framework of the underlying operating system. Therefore there are several multimedia back ends based on different technologies and APIs.

While we try to support our full API on all platforms, platform specific limitations do exist in a few places. This is due to the fact that the feature set supported by those frameworks varies, implying that some functionality might not be available on all platforms. This is especially true for the set of supported file formats and codecs, as well as advanced camera functionality.

Where limitations exist, we aim to document those in the respective classes and methods.

Reference

Examples