QVideoFrameInput Class

The QVideoFrameInput class is used for providing custom video frames to QMediaRecorder or a video output through QMediaCaptureSession. More...

Header: #include <QVideoFrameInput>
CMake: find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia)
qmake: QT += multimedia
Since: Qt 6.8
Inherits: QObject

Public Functions

QVideoFrameInput(QObject *parent = nullptr)
virtual ~QVideoFrameInput() override
QMediaCaptureSession *captureSession() const
bool sendVideoFrame(const QVideoFrame &frame)

Signals

Detailed Description

See also QMediaRecorder, QMediaCaptureSession, QVideoSink, and QVideoOutput.

Member Function Documentation

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

Constructs a new QVideoFrameInput object with parent.

[override virtual noexcept] QVideoFrameInput::~QVideoFrameInput()

Destroys the object.

QMediaCaptureSession *QVideoFrameInput::captureSession() const

Returns the capture session this video frame input is connected to, or a nullptr if the video frame input is not connected to a capture session.

Use QMediaCaptureSession::setVideoFrameInput() to connect the video frame input to a session.

[signal] void QVideoFrameInput::readyToSendVideoFrame()

Signals that a new frame can be sent to the video frame input. After receiving the signal, if you have frames to be sent, invoke sendVideoFrame once or in a loop until it returns false.

See also sendVideoFrame().

bool QVideoFrameInput::sendVideoFrame(const QVideoFrame &frame)

Sends QVideoFrame to QMediaRecorder or a video output through QMediaCaptureSession.

Returns true if the specified frame has been sent successfully to the destination. Returns false, if the frame hasn't been sent, which can happen if the instance is not assigned to QMediaCaptureSession, the session doesn't have video outputs or a media recorder, the media recorder is not started or its queue is full. The signal readyToSendVideoFrame will be sent as soon as the destination is able to handle a new frame.

Sending of an empty video frame is treated by QMediaRecorder as an end of the input stream. QMediaRecorder stops the recording automatically if QMediaRecorder::autoStop is true and all the inputs have reported the end of the stream.