MediaRecorder QML Type
For encoding and recording media generated in a CaptureSession. More...
Import Statement: | import QtMultimedia |
Instantiates: | QMediaRecorder |
Properties
- actualLocation : QUrl
- audioBitRate : int
(since 6.6)
- audioChannelCount : int
(since 6.6)
- audioSampleRate : int
(since 6.6)
- duration : qint64
- encodingMode : enumeration
(since 6.6)
- error : enumeration
- errorString : string
- mediaFormat : MediaFormat
- metaData : mediaMetaData
- outputLocation : QUrl
- quality : enumeration
- recorderState : enumeration
- videoBitRate : int
(since 6.6)
- videoFrameRate : real
(since 6.6)
- videoResolution : Size
(since 6.6)
Signals
- actualLocationChanged(const QUrl &location)
- durationChanged(qint64 duration)
- errorOccurred(Error error, const QString &errorString)
- metaDataChanged()
- recorderStateChanged(RecorderState state)
Methods
Detailed Description
The MediaRecorder element can be used within a CaptureSession to record and encode audio and video captured from a microphone and camera
The code below shows a simple capture session containing a MediaRecorder using the default camera and default audio input.
CaptureSession { id: captureSession camera: Camera { id: camera active: true } audioInput: AudioInput {} recorder: MediaRecorder { id: recorder } }
The code below shows how the recording can be started and stopped.
CameraButton { text: "Record" visible: recorder.recorderState !== MediaRecorder.RecordingState onClicked: recorder.record() } CameraButton { id: stopButton text: "Stop" visible: recorder.recorderState === MediaRecorder.RecordingState onClicked: recorder.stop() }
See also CaptureSession, Camera, AudioInput, and ImageCapture.
Property Documentation
actualLocation : QUrl |
The actual location of the last media content.
The actual location is usually available after recording starts, and reset when new location is set or new recording starts.
audioBitRate : int |
This property holds the bit rate of the compressed audio stream in bits per second.
This property was introduced in Qt 6.6.
audioChannelCount : int |
This property holds the number of audio channels.
This property was introduced in Qt 6.6.
audioSampleRate : int |
This property holds the audio sample rate in Hz.
This property was introduced in Qt 6.6.
duration : qint64 |
This property holds the recorded media duration in milliseconds.
encodingMode : enumeration |
This property holds the encoding mode.
This property was introduced in Qt 6.6.
See also QMediaRecorder::EncodingMode.
error : enumeration |
This property holds the current media recorder error state.
Constant | Description |
---|---|
MediaRecorder.NoError | Not in an error state. |
MediaRecorder.ResourceError | Not enough system resources |
MediaRecorder.FormatError | the current format is not supported. |
MediaRecorder.OutOfSpaceError | No space left on device. |
MediaRecorder.LocationNotWriteable | The output location is not writable. |
errorString : string |
This property holds a string describing the current error state.
See also error.
mediaFormat : MediaFormat |
This property holds the current MediaFormat of the recorder.
metaData : mediaMetaData |
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.
outputLocation : QUrl |
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 errorOccured() signal is emitted.
The location can be relative or empty. If empty the recorder uses the system specific place and file naming scheme.
See also errorOccurred().
quality : enumeration |
Enumerates quality encoding levels.
Constant | Value |
---|---|
MediaRecorder.VeryLowQuality | |
MediaRecorder.LowQuality | |
MediaRecorder.NormalQuality | |
MediaRecorder.HighQuality | |
MediaRecorder.VeryHighQuality |
recorderState : enumeration |
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.
Constant | Description |
---|---|
MediaRecorder.StoppedState | The recorder is not active. |
MediaRecorder.RecordingState | The recording is requested. |
MediaRecorder.PausedState | The recorder is pause. |
videoBitRate : int |
This property holds the bit rate of the compressed video stream in bits per second.
This property was introduced in Qt 6.6.
videoFrameRate : real |
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.
This property was introduced in Qt 6.6.
videoResolution : Size |
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.
This property was introduced in Qt 6.6.
Signal Documentation
actualLocationChanged(const QUrl &location) |
Signals that the actual location of the recorded media has changed.
This signal is usually emitted when recording starts.
Note: The corresponding handler is onActualLocationChanged
.
durationChanged(qint64 duration) |
Signals that the duration of the recorded media has changed.
Note: The corresponding handler is onDurationChanged
.
errorOccurred(Error error, const QString &errorString) |
Signals that an error has occurred.
The errorString contains a description of the error.
Note: The corresponding handler is onErrorOccurred
.
metaDataChanged() |
Signals that a media object's meta-data has changed.
If multiple meta-data elements are changed metaDataChanged() is emitted once.
Note: The corresponding handler is onMetaDataChanged
.
recorderStateChanged(RecorderState state) |
Signals that a media recorder's state has changed.
Note: The corresponding handler is onRecorderStateChanged
.
Method Documentation
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.
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
.
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.
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.