QMediaCaptureSession Class

The QMediaCaptureSession class allows capturing of audio and video content. More...

Header: #include <QMediaCaptureSession>
CMake: find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia)
qmake: QT += multimedia
In QML: CaptureSession
Inherits: QObject

Properties

Public Functions

QMediaCaptureSession(QObject *parent = nullptr)
virtual ~QMediaCaptureSession()
QAudioBufferInput *audioBufferInput() const
QAudioInput *audioInput() const
QAudioOutput *audioOutput() const
QCamera *camera() const
QImageCapture *imageCapture()
QMediaRecorder *recorder()
QScreenCapture *screenCapture()
void setAudioBufferInput(QAudioBufferInput *input)
void setAudioInput(QAudioInput *input)
void setAudioOutput(QAudioOutput *output)
void setCamera(QCamera *camera)
void setImageCapture(QImageCapture *imageCapture)
void setRecorder(QMediaRecorder *recorder)
void setScreenCapture(QScreenCapture *screenCapture)
void setVideoFrameInput(QVideoFrameInput *input)
void setVideoOutput(QObject *output)
void setVideoSink(QVideoSink *sink)
void setWindowCapture(QWindowCapture *windowCapture)
QVideoFrameInput *videoFrameInput() const
QObject *videoOutput() const
QVideoSink *videoSink() const
QWindowCapture *windowCapture()

Signals

Detailed Description

The QMediaCaptureSession is the central class that manages capturing of media on the local device.

You can connect a video input to QMediaCaptureSession using setCamera(), setScreenCapture(), setWindowCapture() or setVideoFrameInput(). A preview of the captured media can be seen by setting a QVideoWidget or QGraphicsVideoItem using setVideoOutput().

You can connect a microphone to QMediaCaptureSession using setAudioInput(), or set your custom audio input using setAudioBufferInput(). The captured sound can be heard by routing the audio to an output device using setAudioOutput().

You can capture still images from a camera by setting a QImageCapture object on the capture session, and record audio/video using a QMediaRecorder.

See also QCamera, QAudioDevice, QMediaRecorder, QImageCapture, QScreenCapture, QWindowCapture, QVideoFrameInput, QMediaRecorder, and QGraphicsVideoItem.

Property Documentation

[since 6.8] audioBufferInput : QAudioBufferInput*

This property holds the object used to send custom audio buffers to QMediaRecorder.

This property was introduced in Qt 6.8.

Access functions:

QAudioBufferInput *audioBufferInput() const
void setAudioBufferInput(QAudioBufferInput *input)

Notifier signal:

void audioBufferInputChanged()

audioInput : QAudioInput*

Returns the device that is being used to capture audio.

Access functions:

QAudioInput *audioInput() const
void setAudioInput(QAudioInput *input)

Notifier signal:

void audioInputChanged()

audioOutput : QAudioOutput*

Returns the audio output for the session.

Access functions:

QAudioOutput *audioOutput() const
void setAudioOutput(QAudioOutput *output)

Notifier signal:

void audioOutputChanged()

camera : QCamera*

This property holds the camera used to capture video.

Record video or take images by adding a camera to the capture session using this property.

Access functions:

QCamera *camera() const
void setCamera(QCamera *camera)

Notifier signal:

void cameraChanged()

imageCapture : QImageCapture*

This property holds the object used to capture still images.

Add a QImageCapture object to the capture session to enable capturing of still images from the camera.

Access functions:

QImageCapture *imageCapture()
void setImageCapture(QImageCapture *imageCapture)

Notifier signal:

void imageCaptureChanged()

recorder : QMediaRecorder*

This property holds the recorder object used to capture audio/video.

Add a QMediaRecorder object to the capture session to enable recording of audio and/or video from the capture session.

Access functions:

QMediaRecorder *recorder()
void setRecorder(QMediaRecorder *recorder)

Notifier signal:

void recorderChanged()

[since 6.5] screenCapture : QScreenCapture*

This property holds the object used to capture a screen.

Record a screen by adding a screen capture object to the capture session using this property.

This property was introduced in Qt 6.5.

Access functions:

QScreenCapture *screenCapture()
void setScreenCapture(QScreenCapture *screenCapture)

Notifier signal:

void screenCaptureChanged()

[since 6.8] videoFrameInput : QVideoFrameInput*

This property holds the object used to send custom video frames to QMediaRecorder or a video output.

This property was introduced in Qt 6.8.

Access functions:

QVideoFrameInput *videoFrameInput() const
void setVideoFrameInput(QVideoFrameInput *input)

Notifier signal:

void videoFrameInputChanged()

videoOutput : QObject*

Returns the video output for the session.

Access functions:

QObject *videoOutput() const
void setVideoOutput(QObject *output)

Notifier signal:

void videoOutputChanged()

[since 6.6] windowCapture : QWindowCapture*

This property holds the object used to capture a window.

Record a window by adding a window capture objet to the capture session using this property.

This property was introduced in Qt 6.6.

Access functions:

QWindowCapture *windowCapture()
void setWindowCapture(QWindowCapture *windowCapture)

Notifier signal:

void windowCaptureChanged()

Member Function Documentation

[explicit] QMediaCaptureSession::QMediaCaptureSession(QObject *parent = nullptr)

Creates a session for media capture from the parent object.

[virtual noexcept] QMediaCaptureSession::~QMediaCaptureSession()

Destroys the session.

void QMediaCaptureSession::setAudioInput(QAudioInput *input)

Sets the audio input device to input. If setting it to an empty QAudioDevice the capture session will use the default input as defined by the operating system.

Note: Setter function for property audioInput.

See also audioInput().

void QMediaCaptureSession::setAudioOutput(QAudioOutput *output)

Sets the audio output device to output.

Setting an audio output device enables audio routing from an audio input device.

Note: Setter function for property audioOutput.

See also audioOutput().

void QMediaCaptureSession::setVideoOutput(QObject *output)

Sets a QObject, (output), to a video preview for the capture session.

A QObject based preview is expected to have an invokable videoSink() method that returns a QVideoSink.

The previously set preview is detached.

Note: Setter function for property videoOutput.

See also videoOutput().

void QMediaCaptureSession::setVideoSink(QVideoSink *sink)

Sets a QVideoSink, (sink), to a video preview for the capture session.

A QObject based preview is expected to have an invokable videoSink() method that returns a QVideoSink.

The previously set preview is detached.

See also videoSink().

QVideoSink *QMediaCaptureSession::videoSink() const

Returns the QVideoSink for the session.

See also setVideoSink().

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.