Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QMediaRecorder Class Reference

\inmodule QtMultimedia More...

#include <qmediarecorder.h>

+ Inheritance diagram for QMediaRecorder:
+ Collaboration diagram for QMediaRecorder:

Signals

void encoderSettingsChanged ()
 Signals when the encoder settings change.
 
void errorChanged ()
 
void mediaFormatChanged ()
 
 Q_REVISION (6, 8) void autoStopChanged()
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 

Public Member Functions

 QMediaRecorder (QObject *parent=nullptr)
 Constructs a media recorder.
 
 ~QMediaRecorder ()
 Destroys a media recorder object.
 
bool isAvailable () const
 Returns true if media recorder service ready to use.
 
QUrl outputLocation () const
 
void setOutputLocation (const QUrl &location)
 
void setOutputDevice (QIODevice *device)
 Set the output IO device for media content.
 
QIODeviceoutputDevice () const
 Returns the output IO device for media content.
 
QUrl actualLocation () const
 
RecorderState recorderState () const
 Returns the current media recorder state.
 
Error error () const
 
QString errorString () const
 
qint64 duration () const
 
QPlatformMediaRecorderplatformRecoder () const
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 

Properties

qint64 duration
 \qmlproperty qint64 QtMultimedia::MediaRecorder::duration
 
QUrl outputLocation
 \qmlproperty QUrl QtMultimedia::MediaRecorder::outputLocation
 
QUrl actualLocation
 \qmlproperty QUrl QtMultimedia::MediaRecorder::actualLocation
 
QMediaRecorder::Error error
 Returns the current error state.
 
QString errorString
 \qmlproperty string QtMultimedia::MediaRecorder::errorString
 
QMediaRecorder::EncodingMode encodingMode
 
QSize videoResolution
 
qreal videoFrameRate
 
int videoBitRate
 
int audioBitRate
 
int audioChannelCount
 
int audioSampleRate
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Friends

class QMediaCaptureSession
 
enum  Quality {
  VeryLowQuality , LowQuality , NormalQuality , HighQuality ,
  VeryHighQuality
}
 \qmlproperty enumeration QtMultimedia::MediaRecorder::quality More...
 
enum  EncodingMode { ConstantQualityEncoding , ConstantBitRateEncoding , AverageBitRateEncoding , TwoPassEncoding }
 Enumerates encoding modes. More...
 
enum  RecorderState { StoppedState , RecordingState , PausedState }
 \qmlproperty enumeration QtMultimedia::MediaRecorder::recorderState More...
 
enum  Error {
  NoError , ResourceError , FormatError , OutOfSpaceError ,
  LocationNotWritable
}
 \qmlproperty enumeration QtMultimedia::MediaRecorder::error More...
 
QMediaRecorder::RecorderState recorderState
 The current state of the media recorder.
 
QMediaMetaData metaData
 \qmlproperty mediaMetaData QtMultimedia::MediaRecorder::metaData
 
QMediaFormat mediaFormat
 \qmlproperty MediaFormat QtMultimedia::MediaRecorder::mediaFormat
 
Quality quality
 Returns the recording quality.
 
bool autoStop
 This property controls whether the media recorder stops automatically when all media inputs have reported the end of the stream or have been deactivated.
 
QMediaFormat mediaFormat () const
 
void setMediaFormat (const QMediaFormat &format)
 
EncodingMode encodingMode () const
 \qmlproperty enumeration QtMultimedia::MediaRecorder::encodingMode
 
void setEncodingMode (EncodingMode)
 Sets the encoding mode setting.
 
Quality quality () const
 
void setQuality (Quality quality)
 
QSize videoResolution () const
 \qmlproperty Size QtMultimedia::MediaRecorder::videoResolution
 
void setVideoResolution (const QSize &)
 Sets the resolution of the encoded video to {size}.
 
void setVideoResolution (int width, int height)
 Sets the width and height of the resolution of the encoded video.
 
qreal videoFrameRate () const
 \qmlproperty real QtMultimedia::MediaRecorder::videoFrameRate
 
void setVideoFrameRate (qreal frameRate)
 Sets the video frameRate.
 
int videoBitRate () const
 \qmlproperty int QtMultimedia::MediaRecorder::videoBitRate
 
void setVideoBitRate (int bitRate)
 Sets the video bitRate in bits per second.
 
int audioBitRate () const
 \qmlproperty int QtMultimedia::MediaRecorder::audioBitRate
 
void setAudioBitRate (int bitRate)
 Sets the audio bitRate in bits per second.
 
int audioChannelCount () const
 \qmlproperty int QtMultimedia::MediaRecorder::audioChannelCount
 
void setAudioChannelCount (int channels)
 Sets the number of audio channels.
 
int audioSampleRate () const
 \qmlproperty int QtMultimedia::MediaRecorder::audioSampleRate
 
void setAudioSampleRate (int sampleRate)
 Sets the audio sampleRate in Hz.
 
QMediaMetaData metaData () const
 
void setMetaData (const QMediaMetaData &metaData)
 Sets the meta data to metaData.
 
void addMetaData (const QMediaMetaData &metaData)
 Adds metaData to the recorded media.
 
bool autoStop () const
 
void setAutoStop (bool autoStop)
 
QMediaCaptureSessioncaptureSession () const
 Returns the media capture session.
 
void record ()
 \qmlmethod QtMultimedia::MediaRecorder::record()
 
void pause ()
 \qmlmethod QtMultimedia::MediaRecorder::pause()
 
void stop ()
 \qmlmethod QtMultimedia::MediaRecorder::stop()
 
void recorderStateChanged (RecorderState state)
 \qmlsignal QtMultimedia::MediaRecorder::recorderStateChanged(RecorderState state)
 
void durationChanged (qint64 duration)
 \qmlsignal QtMultimedia::MediaRecorder::durationChanged(qint64 duration)
 
void actualLocationChanged (const QUrl &location)
 \qmlsignal QtMultimedia::MediaRecorder::actualLocationChanged(const QUrl &location)
 
void errorOccurred (Error error, const QString &errorString)
 \qmlsignal QtMultimedia::MediaRecorder::errorOccurred(Error error, const QString &errorString)
 
void metaDataChanged ()
 \qmlsignal QtMultimedia::MediaRecorder::metaDataChanged()
 
void encodingModeChanged ()
 Signals when the encoding mode changes.
 
void qualityChanged ()
 Signals when the recording quality changes.
 
void videoResolutionChanged ()
 Signals when the video recording resolution changes.
 
void videoFrameRateChanged ()
 Signals when the recording video frame rate changes.
 
void videoBitRateChanged ()
 Signals when the recording video bit rate changes.
 
void audioBitRateChanged ()
 Signals when the recording audio bit rate changes.
 
void audioChannelCountChanged ()
 Signals when the recording audio channel count changes.
 
void audioSampleRateChanged ()
 Signals when the recording audio sample rate changes.
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

\inmodule QtMultimedia

The QMediaRecorder class is used for encoding and recording a capture session.

Use the QMediaRecorder class to encode and record media generated in \l QMediaCaptureSession. You can generate: \list

To record media, connect a generator to a corresponding media capture session.

Performance of video encoding and recording is limited by the hardware, the operating system, the installed graphic drivers, and the input video format. If QCamera, QScreenCapture, or QWindowCapture produces video frames faster than QMediaRecorder can encode and record them, the recorder may drop some frames. This is likely to occur if the input frame resolution is high, 4K for example, and hardware-accelerated encoding is unavailable. If you generate input video via QVideoFrameInput, the method QVideoFrameInput::sendVideoFrame will do nothing and return false whenever this limitation is reached and the internal frame queue is full. Rely on the signal QVideoFrameInput::readyToSendVideoFrame to know when the recorder is ready to receive new frames again. If you cannot change the rate of video frame generation and dropping frames is undesirable, we recommend implementing your own frame queue on top of QVideoFrameInput, considering the memory limitations of the hardware.

Definition at line 27 of file qmediarecorder.h.

Member Enumeration Documentation

◆ EncodingMode

Enumerates encoding modes.

\value ConstantQualityEncoding Encoding will aim to have a constant quality, adjusting bitrate to fit. \value ConstantBitRateEncoding Encoding will use a constant bit rate, adjust quality to fit. \value AverageBitRateEncoding Encoding will try to keep an average bitrate setting, but will use more or less as needed. \value TwoPassEncoding The media will first be processed to determine the characteristics, and then processed a second time allocating more bits to the areas that need it.

Enumerator
ConstantQualityEncoding 
ConstantBitRateEncoding 
AverageBitRateEncoding 
TwoPassEncoding 

Definition at line 58 of file qmediarecorder.h.

◆ Error

\qmlproperty enumeration QtMultimedia::MediaRecorder::error

This property holds the current media recorder error state.

\value MediaRecorder.NoError Not in an error state. \value MediaRecorder.ResourceError Not enough system resources \value MediaRecorder.FormatError the current format is not supported. \value MediaRecorder.OutOfSpaceError No space left on device. \value MediaRecorder.LocationNotWriteable The output location is not writable.

\value NoError No Errors. \value ResourceError Device is not ready or not available. \value FormatError Current format is not supported. \value OutOfSpaceError No space left on device. \value LocationNotWritable The output location is not writable.

Enumerator
NoError 
ResourceError 
FormatError 
OutOfSpaceError 
LocationNotWritable 

Definition at line 75 of file qmediarecorder.h.

◆ Quality

\qmlproperty enumeration QtMultimedia::MediaRecorder::quality

Enumerates quality encoding levels.

\value MediaRecorder.VeryLowQuality \value MediaRecorder.LowQuality \value MediaRecorder.NormalQuality \value MediaRecorder.HighQuality \value MediaRecorder.VeryHighQuality

Enumerates quality encoding levels.

\value VeryLowQuality \value LowQuality \value NormalQuality \value HighQuality \value VeryHighQuality

Enumerator
VeryLowQuality 
LowQuality 
NormalQuality 
HighQuality 
VeryHighQuality 

Definition at line 48 of file qmediarecorder.h.

◆ RecorderState

\qmlproperty enumeration QtMultimedia::MediaRecorder::recorderState

This property holds the current media recorder state.

The state property represents the user request and is changed synchronously during record(), pause() or stop() calls. RecorderSstate may also change asynchronously when recording fails.

\value MediaRecorder.StoppedState The recorder is not active. \value MediaRecorder.RecordingState The recording is requested. \value MediaRecorder.PausedState The recorder is pause.

\value StoppedState The recorder is not active. \value RecordingState The recording is requested. \value PausedState The recorder is paused.

Enumerator
StoppedState 
RecordingState 
PausedState 

Definition at line 67 of file qmediarecorder.h.

Constructor & Destructor Documentation

◆ QMediaRecorder()

QMediaRecorder::QMediaRecorder ( QObject * parent = nullptr)

Constructs a media recorder.

The media recorder is a child of {parent}.

Definition at line 139 of file qmediarecorder.cpp.

◆ ~QMediaRecorder()

QMediaRecorder::~QMediaRecorder ( )

Destroys a media recorder object.

Definition at line 166 of file qmediarecorder.cpp.

Member Function Documentation

◆ actualLocation()

QUrl QMediaRecorder::actualLocation ( ) const

Definition at line 344 of file qmediarecorder.cpp.

◆ actualLocationChanged

void QMediaRecorder::actualLocationChanged ( const QUrl & location)
signal

\qmlsignal QtMultimedia::MediaRecorder::actualLocationChanged(const QUrl &location)

Signals that the actual location of the recorded media has changed.

This signal is usually emitted when recording starts.

Signals that the actual location of the recorded media has changed. This signal is usually emitted when recording starts.

◆ addMetaData()

void QMediaRecorder::addMetaData ( const QMediaMetaData & metaData)

Adds metaData to the recorded media.

Definition at line 664 of file qmediarecorder.cpp.

◆ audioBitRate()

int QMediaRecorder::audioBitRate ( ) const

\qmlproperty int QtMultimedia::MediaRecorder::audioBitRate

Since
6.6

This property holds the bit rate of the compressed audio stream in bits per second.

Returns the bit rate of the compressed audio stream in bits per second.

Definition at line 994 of file qmediarecorder.cpp.

◆ audioBitRateChanged

void QMediaRecorder::audioBitRateChanged ( )
signal

Signals when the recording audio bit rate changes.

◆ audioChannelCount()

int QMediaRecorder::audioChannelCount ( ) const

\qmlproperty int QtMultimedia::MediaRecorder::audioChannelCount

Since
6.6

This property holds the number of audio channels.

Returns the number of audio channels.

Definition at line 1026 of file qmediarecorder.cpp.

◆ audioChannelCountChanged

void QMediaRecorder::audioChannelCountChanged ( )
signal

Signals when the recording audio channel count changes.

◆ audioSampleRate()

int QMediaRecorder::audioSampleRate ( ) const

\qmlproperty int QtMultimedia::MediaRecorder::audioSampleRate

Since
6.6

This property holds the audio sample rate in Hz.

Returns the audio sample rate in Hz.

Definition at line 1061 of file qmediarecorder.cpp.

◆ audioSampleRateChanged

void QMediaRecorder::audioSampleRateChanged ( )
signal

Signals when the recording audio sample rate changes.

◆ autoStop()

bool QMediaRecorder::autoStop ( ) const

Definition at line 692 of file qmediarecorder.cpp.

◆ captureSession()

QMediaCaptureSession * QMediaRecorder::captureSession ( ) const

Returns the media capture session.

Definition at line 734 of file qmediarecorder.cpp.

◆ duration()

qint64 QMediaRecorder::duration ( ) const

Definition at line 407 of file qmediarecorder.cpp.

◆ durationChanged

void QMediaRecorder::durationChanged ( qint64 duration)
signal

\qmlsignal QtMultimedia::MediaRecorder::durationChanged(qint64 duration)

Signals that the duration of the recorded media has changed.

Signals that the duration of the recorded media has changed.

◆ encoderSettingsChanged

void QMediaRecorder::encoderSettingsChanged ( )
signal

Signals when the encoder settings change.

◆ encodingMode()

QMediaRecorder::EncodingMode QMediaRecorder::encodingMode ( ) const

\qmlproperty enumeration QtMultimedia::MediaRecorder::encodingMode

Since
6.6

This property holds the encoding mode.

See also
QMediaRecorder::EncodingMode

Returns the encoding mode.

See also
EncodingMode

Definition at line 815 of file qmediarecorder.cpp.

◆ encodingModeChanged

void QMediaRecorder::encodingModeChanged ( )
signal

Signals when the encoding mode changes.

◆ error()

QMediaRecorder::Error QMediaRecorder::error ( ) const

Definition at line 369 of file qmediarecorder.cpp.

◆ errorChanged

void QMediaRecorder::errorChanged ( )
signal

◆ errorOccurred

void QMediaRecorder::errorOccurred ( QMediaRecorder::Error error,
const QString & errorString )
signal

\qmlsignal QtMultimedia::MediaRecorder::errorOccurred(Error error, const QString &errorString)

Signals that an error has occurred.

The errorString contains a description of the error.

Signals that an error has occurred, with errorString containing a description of the error.

◆ errorString()

QString QMediaRecorder::errorString ( ) const

Definition at line 389 of file qmediarecorder.cpp.

◆ isAvailable()

bool QMediaRecorder::isAvailable ( ) const

Returns true if media recorder service ready to use.

Definition at line 273 of file qmediarecorder.cpp.

◆ mediaFormat()

QMediaFormat QMediaRecorder::mediaFormat ( ) const

Definition at line 787 of file qmediarecorder.cpp.

◆ mediaFormatChanged

void QMediaRecorder::mediaFormatChanged ( )
signal

◆ metaData()

QMediaMetaData QMediaRecorder::metaData ( ) const

Definition at line 640 of file qmediarecorder.cpp.

◆ metaDataChanged

void QMediaRecorder::metaDataChanged ( )
signal

\qmlsignal QtMultimedia::MediaRecorder::metaDataChanged()

Signals that a media object's meta-data has changed.

If multiple meta-data elements are changed metaDataChanged() is emitted once.

Signals that a media object's meta-data has changed.

If multiple meta-data elements are changed metaDataChanged() is emitted once.

◆ outputDevice()

QIODevice * QMediaRecorder::outputDevice ( ) const

Returns the output IO device for media content.

See also
setOutputDevice()

Definition at line 338 of file qmediarecorder.cpp.

◆ outputLocation()

QUrl QMediaRecorder::outputLocation ( ) const

Definition at line 278 of file qmediarecorder.cpp.

◆ pause

void QMediaRecorder::pause ( )
slot

\qmlmethod QtMultimedia::MediaRecorder::pause()

Pauses recording.

The recorder state is changed to QMediaRecorder.PausedState.

Depending on the platform, pausing recording may be not supported. In this case the recorder state is unchanged.

Pauses recording.

The recorder state is changed to QMediaRecorder::PausedState.

Depending on the platform, pausing recording may be not supported. In this case the recorder state is unchanged.

Definition at line 501 of file qmediarecorder.cpp.

◆ platformRecoder()

QPlatformMediaRecorder * QMediaRecorder::platformRecoder ( ) const

Definition at line 177 of file qmediarecorder.cpp.

◆ Q_REVISION

QMediaRecorder::Q_REVISION ( 6 ,
8  )
signal

◆ quality()

QMediaRecorder::Quality QMediaRecorder::quality ( ) const

Definition at line 849 of file qmediarecorder.cpp.

◆ qualityChanged

void QMediaRecorder::qualityChanged ( )
signal

Signals when the recording quality changes.

◆ record

void QMediaRecorder::record ( )
slot

\qmlmethod QtMultimedia::MediaRecorder::record()

Starts recording.

While the recorder state is changed immediately to MediaRecorder.RecordingState, recording may start asynchronously.

If recording fails, the error() signal is emitted with recorder state being reset back to {QMediaRecorder.StoppedState}.

This method updates \l actualLocation according to its generation rules.

Note
On mobile devices, recording will happen in the orientation the device had when calling record and is locked for the duration of the recording. To avoid artifacts on the user interface, we recommend to keep the user interface locked to the same orientation as long as the recording is ongoing using the contentOrientation property of the Window and unlock it again once the recording is finished.

Starts recording.

While the recorder state is changed immediately to cQMediaRecorder::RecordingState}, recording may start asynchronously.

If recording fails error() signal is emitted with recorder state being reset back to {QMediaRecorder::StoppedState}.

This method updates \l actualLocation according to its generation rules.

Note
On mobile devices, recording will happen in the orientation the device had when calling record and is locked for the duration of the recording. To avoid artifacts on the user interface, we recommend to keep the user interface locked to the same orientation as long as the recording is ongoing using the contentOrientation property of QWindow and unlock it again once the recording is finished.

Definition at line 454 of file qmediarecorder.cpp.

◆ recorderState()

QMediaRecorder::RecorderState QMediaRecorder::recorderState ( ) const

Returns the current media recorder state.

See also
QMediaRecorder::RecorderState

Definition at line 356 of file qmediarecorder.cpp.

◆ recorderStateChanged

void QMediaRecorder::recorderStateChanged ( QMediaRecorder::RecorderState state)
signal

\qmlsignal QtMultimedia::MediaRecorder::recorderStateChanged(RecorderState state)

Signals that a media recorder's state has changed.

Signals that a media recorder's state has changed.

◆ setAudioBitRate()

void QMediaRecorder::setAudioBitRate ( int bitRate)

Sets the audio bitRate in bits per second.

Definition at line 1008 of file qmediarecorder.cpp.

◆ setAudioChannelCount()

void QMediaRecorder::setAudioChannelCount ( int channels)

Sets the number of audio channels.

A value of -1 indicates the recorder should make an optimal choice based on what is available from the audio source and the limitations of the codec.

Definition at line 1043 of file qmediarecorder.cpp.

◆ setAudioSampleRate()

void QMediaRecorder::setAudioSampleRate ( int sampleRate)

Sets the audio sampleRate in Hz.

A value of -1 indicates the recorder should make an optimal choice based on what is available from the audio source, and the limitations of the codec.

Definition at line 1077 of file qmediarecorder.cpp.

◆ setAutoStop()

void QMediaRecorder::setAutoStop ( bool autoStop)

Definition at line 699 of file qmediarecorder.cpp.

◆ setEncodingMode()

void QMediaRecorder::setEncodingMode ( EncodingMode mode)

Sets the encoding mode setting.

If ConstantQualityEncoding is set, the quality encoding parameter is used and bit rates are ignored, otherwise the bitrates are used.

See also
encodingMode(), EncodingMode

Definition at line 835 of file qmediarecorder.cpp.

◆ setMediaFormat()

void QMediaRecorder::setMediaFormat ( const QMediaFormat & format)

Definition at line 793 of file qmediarecorder.cpp.

◆ setMetaData()

void QMediaRecorder::setMetaData ( const QMediaMetaData & metaData)

Sets the meta data to metaData.

Note
To ensure that meta-data is set correctly, it should be set before starting the recording. Once the recording is started, any meta-data set will be attached to the next recording.

Definition at line 653 of file qmediarecorder.cpp.

◆ setOutputDevice()

void QMediaRecorder::setOutputDevice ( QIODevice * device)

Set the output IO device for media content.

The device must have been opened in the \l{QIODevice::WriteOnly}{WriteOnly} or \l{QIODevice::ReadWrite}{ReadWrite} modes before the recording starts.

The media recorder doesn't take ownership of the specified device. If the recording has been started, the device must be kept alive and open until the signal recorderStateChanged(StoppedState) is emitted.

This method resets \l actualLocation immediately unless the specified device is null.

If a writable output device is assigned to the recorder, \l outputLocation is ignored, and \l actualLocation is not generated when recording starts. This behavior may change in the future, so we recommend setting only one output, either outputLocation or outputDevice.

QMediaRecorder::setOutputDevice is only supported with the FFmpeg backend.

See also
outputDevice(), outputLocation

Definition at line 319 of file qmediarecorder.cpp.

◆ setOutputLocation()

void QMediaRecorder::setOutputLocation ( const QUrl & location)

Definition at line 283 of file qmediarecorder.cpp.

◆ setQuality()

void QMediaRecorder::setQuality ( Quality quality)

Definition at line 860 of file qmediarecorder.cpp.

◆ setVideoBitRate()

void QMediaRecorder::setVideoBitRate ( int bitRate)

Sets the video bitRate in bits per second.

Definition at line 976 of file qmediarecorder.cpp.

◆ setVideoFrameRate()

void QMediaRecorder::setVideoFrameRate ( qreal frameRate)

Sets the video frameRate.

A value of 0 indicates the recorder should make an optimal choice based on what is available from the video source and the limitations of the codec.

Definition at line 944 of file qmediarecorder.cpp.

◆ setVideoResolution() [1/2]

void QMediaRecorder::setVideoResolution ( const QSize & size)

Sets the resolution of the encoded video to {size}.

Pass an empty QSize to make the recorder choose an optimal resolution based on what is available from the video source and the limitations of the codec.

Definition at line 899 of file qmediarecorder.cpp.

◆ setVideoResolution() [2/2]

void QMediaRecorder::setVideoResolution ( int width,
int height )
inline

Sets the width and height of the resolution of the encoded video.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 116 of file qmediarecorder.h.

◆ stop

void QMediaRecorder::stop ( )
slot

\qmlmethod QtMultimedia::MediaRecorder::stop()

Stops the recording.

The recorder will stop the recording. Processing pending video and audio data might however still take some time. The recording is finished, once the state of the media recorder changes to QMediaRecorder::StoppedState.

The recorder will stop the recording. Processing pending video and audio data might however still take some time. The recording is finished, once the state of the media recorder changes to QMediaRecorder::StoppedState.

Definition at line 521 of file qmediarecorder.cpp.

◆ videoBitRate()

int QMediaRecorder::videoBitRate ( ) const

\qmlproperty int QtMultimedia::MediaRecorder::videoBitRate

Since
6.6

This property holds the bit rate of the compressed video stream in bits per second.

Returns the bit rate of the compressed video stream in bits per second.

Definition at line 962 of file qmediarecorder.cpp.

◆ videoBitRateChanged

void QMediaRecorder::videoBitRateChanged ( )
signal

Signals when the recording video bit rate changes.

◆ videoFrameRate()

qreal QMediaRecorder::videoFrameRate ( ) const

\qmlproperty real QtMultimedia::MediaRecorder::videoFrameRate

Since
6.6

This property holds the video frame rate.

A value of 0 indicates the recorder should make an optimal choice based on what is available from the video source and the limitations of the codec.

Returns the video frame rate.

Definition at line 927 of file qmediarecorder.cpp.

◆ videoFrameRateChanged

void QMediaRecorder::videoFrameRateChanged ( )
signal

Signals when the recording video frame rate changes.

◆ videoResolution()

QSize QMediaRecorder::videoResolution ( ) const

\qmlproperty Size QtMultimedia::MediaRecorder::videoResolution

Since
6.6

This property holds the resolution of the encoded video.

Set an empty Size to make the recorder choose an optimal resolution based on what is available from the video source and the limitations of the codec.

Returns the resolution of the encoded video.

Definition at line 882 of file qmediarecorder.cpp.

◆ videoResolutionChanged

void QMediaRecorder::videoResolutionChanged ( )
signal

Signals when the video recording resolution changes.

Friends And Related Symbol Documentation

◆ QMediaCaptureSession

friend class QMediaCaptureSession
friend

Definition at line 172 of file qmediarecorder.h.

Property Documentation

◆ actualLocation

QUrl QMediaRecorder::actualLocation
read

\qmlproperty QUrl QtMultimedia::MediaRecorder::actualLocation

The actual location of the last media content.

The actual location is reset when a new \l outputLocation is assigned. When \l record() is invoked, the recorder generates the actual location basing on the following rules. \list

  • If outputLocation is empty, a directory, or a file without an extension, the recorder generates the appropriate extension based on the selected media format and system MIME types.
  • If outputLocation is a directory, the recorder generates a new file name within it.
  • If outputLocation is empty, the recorder generates a new file name in the system-specific directory for audio or video.
  • The recorder generates the actual location before emitting recorderStateChanged(RecordingState). \endlist

The actual location of the last media content.

The actual location is reset when a new \l outputLocation or a non-null \l outputDevice is assigned. When \l record() is invoked and outputDevice is null or not writable, the recorder generates the actual location basing on the following rules. \list

  • If outputLocation is empty, a directory, or a file without an extension, the recorder generates the appropriate extension based on the selected media format and system MIME types.
  • If outputLocation is a directory, the recorder generates a new file name within it.
  • If outputLocation is empty, the recorder generates a new file name in the system-specific directory for audio or video.
  • The recorder generates the actual location before emitting recorderStateChanged(RecordingState). \endlist

Definition at line 33 of file qmediarecorder.h.

◆ audioBitRate

int QMediaRecorder::audioBitRate
readwrite

Definition at line 43 of file qmediarecorder.h.

◆ audioChannelCount

int QMediaRecorder::audioChannelCount
readwrite

Definition at line 44 of file qmediarecorder.h.

◆ audioSampleRate

int QMediaRecorder::audioSampleRate
readwrite

Definition at line 45 of file qmediarecorder.h.

◆ autoStop

bool QMediaRecorder::autoStop
readwrite

This property controls whether the media recorder stops automatically when all media inputs have reported the end of the stream or have been deactivated.

The end of the stream is reported by sending an empty media frame, which you can send explicitly via \l QVideoFrameInput or \l QAudioBufferInput.

Video inputs, specificly, \l QCamera, \l QScreenCapture and \l QWindowCapture, can be deactivated via the function setActive.

Defaults to false.

QMediaRecorder::autoStop is only supported with the FFmpeg backend.

See also
QCamera, QScreenCapture, QWindowCapture

Definition at line 46 of file qmediarecorder.h.

◆ duration

qint64 QMediaRecorder::duration
read

\qmlproperty qint64 QtMultimedia::MediaRecorder::duration

This property holds the recorded media duration in milliseconds.

the recorded media duration in milliseconds.

Definition at line 31 of file qmediarecorder.h.

◆ encodingMode

QMediaRecorder::EncodingMode QMediaRecorder::encodingMode
readwrite

Definition at line 39 of file qmediarecorder.h.

◆ error

QMediaRecorder::Error QMediaRecorder::error
read

Returns the current error state.

See also
errorString()

Definition at line 35 of file qmediarecorder.h.

◆ errorString

QString QMediaRecorder::errorString
read

\qmlproperty string QtMultimedia::MediaRecorder::errorString

This property holds a string describing the current error state.

See also
error

Returns a string describing the current error state.

See also
error()

Definition at line 36 of file qmediarecorder.h.

◆ mediaFormat

QMediaFormat QMediaRecorder::mediaFormat
readwrite

\qmlproperty MediaFormat QtMultimedia::MediaRecorder::mediaFormat

This property holds the current MediaFormat of the recorder.

Returns the recording media format.

Definition at line 37 of file qmediarecorder.h.

◆ metaData

QMediaMetaData QMediaRecorder::metaData
readwrite

\qmlproperty mediaMetaData QtMultimedia::MediaRecorder::metaData

This property holds meta data associated with the recording.

When a recording is started, any meta-data assigned will be attached to that recording.

Note
Ensure that meta-data is assigned correctly by assigning it before starting the recording.
See also
mediaMetaData

Returns the metaData associated with the recording.

Definition at line 34 of file qmediarecorder.h.

◆ outputLocation

QUrl QMediaRecorder::outputLocation
readwrite

\qmlproperty QUrl QtMultimedia::MediaRecorder::outputLocation

The destination location of media content.

Setting the location can fail, for example when the service supports only local file system locations but a network URL was passed. If the operation fails an \l errorOccured() signal is emitted.

The output location can be empty, a directory, or a file. The path to a directory or file can be relative or absolute. The \l record() method generates the actual location according to the specified output location and system-specific settings. Refer to the \l actualLocation property description for details.

See also
actualLocation, errorOccurred()

The destination location of media content.

Setting the location can fail, for example when the service supports only local file system locations but a network URL was passed. If the operation fails, the \l errorOccured() signal is emitted.

The output location is ignored if a writable \l outputDevice has been assigned to the recorder. This behavior may change in the future, so we recommend setting only one output, either outputLocation or outputDevice.

The output location can be empty, a directory, or a file. The path to a directory or file can be relative or absolute. The \l record() method generates the actual location according to the specified output location and system-specific settings. Refer to the \l actualLocation property description for details.

See also
actualLocation, outputDevice()

Definition at line 32 of file qmediarecorder.h.

◆ quality

Quality QMediaRecorder::quality
readwrite

Returns the recording quality.

Definition at line 38 of file qmediarecorder.h.

◆ recorderState

QMediaRecorder::RecorderState QMediaRecorder::recorderState
read

The current state of the media recorder.

The state property represents the user request and is changed synchronously during record(), pause() or stop() calls. Recorder state may also change asynchronously when recording fails.

Definition at line 30 of file qmediarecorder.h.

◆ videoBitRate

int QMediaRecorder::videoBitRate
readwrite

Definition at line 42 of file qmediarecorder.h.

◆ videoFrameRate

qreal QMediaRecorder::videoFrameRate
readwrite

Definition at line 41 of file qmediarecorder.h.

◆ videoResolution

QSize QMediaRecorder::videoResolution
readwrite

Definition at line 40 of file qmediarecorder.h.


The documentation for this class was generated from the following files: