QMediaRecorder¶
The QMediaRecorder
class is used for encoding and recording a capture session. More…
Synopsis¶
Functions¶
def
actualLocation
()def
addMetaData
(metaData)def
audioBitRate
()def
audioChannelCount
()def
audioSampleRate
()def
captureSession
()def
duration
()def
encodingMode
()def
error
()def
errorString
()def
isAvailable
()def
mediaFormat
()def
metaData
()def
outputLocation
()def
quality
()def
recorderState
()def
setAudioBitRate
(bitRate)def
setAudioChannelCount
(channels)def
setAudioSampleRate
(sampleRate)def
setEncodingMode
(arg__1)def
setMediaFormat
(format)def
setMetaData
(metaData)def
setOutputLocation
(location)def
setQuality
(quality)def
setVideoBitRate
(bitRate)def
setVideoFrameRate
(frameRate)def
setVideoResolution
(arg__1)def
setVideoResolution
(width, height)def
videoBitRate
()def
videoFrameRate
()def
videoResolution
()
Slots¶
Signals¶
def
actualLocationChanged
(location)def
audioBitRateChanged
()def
audioChannelCountChanged
()def
audioSampleRateChanged
()def
durationChanged
(duration)def
encoderSettingsChanged
()def
encodingModeChanged
()def
errorChanged
()def
errorOccurred
(error, errorString)def
mediaFormatChanged
()def
metaDataChanged
()def
qualityChanged
()def
recorderStateChanged
(state)def
videoBitRateChanged
()def
videoFrameRateChanged
()def
videoResolutionChanged
()
Detailed Description¶
The QMediaRecorder
class is a class for encoding and recording media generated in a QMediaCaptureSession
.
session = QMediaCaptureSession() audioInput = QAudioInput() session.setAudioInput(input) recorder = QMediaRecorder() session.setMediaRecorder(recorder) recorder.setQuality(QMediaRecorder.HighQuality) recorder.setOutputLocation(QUrl.fromLocalFile("test.mp3")) recorder.record()
- class PySide6.QtMultimedia.QMediaRecorder([parent=None])¶
- Parameters
parent –
PySide6.QtCore.QObject
Constructs a media recorder which records the media produced by a microphone and camera. The media recorder is a child of parent
.
- PySide6.QtMultimedia.QMediaRecorder.Quality¶
Enumerates quality encoding levels.
Constant
Description
QMediaRecorder.VeryLowQuality
QMediaRecorder.LowQuality
QMediaRecorder.NormalQuality
QMediaRecorder.HighQuality
QMediaRecorder.VeryHighQuality
New in version 6.1.
- PySide6.QtMultimedia.QMediaRecorder.EncodingMode¶
Enumerates encoding modes.
Constant
Description
QMediaRecorder.ConstantQualityEncoding
Encoding will aim to have a constant quality, adjusting bitrate to fit.
QMediaRecorder.ConstantBitRateEncoding
Encoding will use a constant bit rate, adjust quality to fit.
QMediaRecorder.AverageBitRateEncoding
Encoding will try to keep an average bitrate setting, but will use more or less as needed.
QMediaRecorder.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.
New in version 6.1.
- PySide6.QtMultimedia.QMediaRecorder.RecorderState¶
Constant
Description
QMediaRecorder.StoppedState
The recorder is not active.
QMediaRecorder.RecordingState
The recording is requested.
QMediaRecorder.PausedState
The recorder is paused.
New in version 6.1.
- PySide6.QtMultimedia.QMediaRecorder.Error¶
Constant
Description
QMediaRecorder.NoError
No Errors.
QMediaRecorder.ResourceError
Device is not ready or not available.
QMediaRecorder.FormatError
Current format is not supported.
QMediaRecorder.OutOfSpaceError
No space left on device.
QMediaRecorder.LocationNotWritable
The output location is not writable.
New in version 6.1.
- PySide6.QtMultimedia.QMediaRecorder.actualLocation()¶
- Return type
This property holds 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.
- PySide6.QtMultimedia.QMediaRecorder.actualLocationChanged(location)¶
- Parameters
location –
PySide6.QtCore.QUrl
- PySide6.QtMultimedia.QMediaRecorder.addMetaData(metaData)¶
- Parameters
metaData –
PySide6.QtMultimedia.QMediaMetaData
- PySide6.QtMultimedia.QMediaRecorder.audioBitRate()¶
- Return type
int
Returns the bit rate of the compressed audio stream in bits per second.
See also
- PySide6.QtMultimedia.QMediaRecorder.audioBitRateChanged()¶
- PySide6.QtMultimedia.QMediaRecorder.audioChannelCount()¶
- Return type
int
Returns the number of audio channels.
See also
- PySide6.QtMultimedia.QMediaRecorder.audioChannelCountChanged()¶
- PySide6.QtMultimedia.QMediaRecorder.audioSampleRate()¶
- Return type
int
Returns the audio sample rate in Hz.
See also
- PySide6.QtMultimedia.QMediaRecorder.audioSampleRateChanged()¶
- PySide6.QtMultimedia.QMediaRecorder.captureSession()¶
- Return type
- PySide6.QtMultimedia.QMediaRecorder.duration()¶
- Return type
int
This property holds the recorded media duration in milliseconds..
- PySide6.QtMultimedia.QMediaRecorder.durationChanged(duration)¶
- Parameters
duration – int
- PySide6.QtMultimedia.QMediaRecorder.encoderSettingsChanged()¶
- PySide6.QtMultimedia.QMediaRecorder.encodingMode()¶
- Return type
Returns the encoding mode.
See also
setEncodingMode()
EncodingMode
- PySide6.QtMultimedia.QMediaRecorder.encodingModeChanged()¶
- PySide6.QtMultimedia.QMediaRecorder.errorChanged()¶
- PySide6.QtMultimedia.QMediaRecorder.errorOccurred(error, errorString)¶
- Parameters
error –
Error
errorString – str
- PySide6.QtMultimedia.QMediaRecorder.errorString()¶
- Return type
str
- PySide6.QtMultimedia.QMediaRecorder.isAvailable()¶
- Return type
bool
Returns true
if media recorder service ready to use.
- PySide6.QtMultimedia.QMediaRecorder.mediaFormat()¶
- Return type
- PySide6.QtMultimedia.QMediaRecorder.mediaFormatChanged()¶
- PySide6.QtMultimedia.QMediaRecorder.metaData()¶
- Return type
- PySide6.QtMultimedia.QMediaRecorder.metaDataChanged()¶
- PySide6.QtMultimedia.QMediaRecorder.outputLocation()¶
- Return type
This property holds 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 output location can be relative or empty; in the latter case the recorder uses the system specific place and file naming scheme.
- PySide6.QtMultimedia.QMediaRecorder.pause()¶
Pauses recording.
The recorder state is changed to PausedState
.
Depending on the platform, pausing recording may be not supported. In this case the recorder state is unchanged.
- PySide6.QtMultimedia.QMediaRecorder.qualityChanged()¶
- PySide6.QtMultimedia.QMediaRecorder.record()¶
Start recording.
While the recorder state is changed immediately to c{ RecordingState
}, recording may start asynchronously.
If recording fails 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 QWindow
and unlock it again once the recording is finished.
- PySide6.QtMultimedia.QMediaRecorder.recorderState()¶
- Return type
This property holds 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.
- PySide6.QtMultimedia.QMediaRecorder.recorderStateChanged(state)¶
- Parameters
state –
RecorderState
- PySide6.QtMultimedia.QMediaRecorder.setAudioBitRate(bitRate)¶
- Parameters
bitRate – int
Sets the audio bitRate
in bits per second.
See also
- PySide6.QtMultimedia.QMediaRecorder.setAudioChannelCount(channels)¶
- Parameters
channels – int
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.
See also
- PySide6.QtMultimedia.QMediaRecorder.setAudioSampleRate(sampleRate)¶
- Parameters
sampleRate – int
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.
See also
- PySide6.QtMultimedia.QMediaRecorder.setEncodingMode(arg__1)¶
- Parameters
arg__1 –
EncodingMode
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
- PySide6.QtMultimedia.QMediaRecorder.setMediaFormat(format)¶
- Parameters
format –
PySide6.QtMultimedia.QMediaFormat
- PySide6.QtMultimedia.QMediaRecorder.setMetaData(metaData)¶
- Parameters
metaData –
PySide6.QtMultimedia.QMediaMetaData
- PySide6.QtMultimedia.QMediaRecorder.setOutputLocation(location)¶
- Parameters
location –
PySide6.QtCore.QUrl
This property holds 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 output location can be relative or empty; in the latter case the recorder uses the system specific place and file naming scheme.
- PySide6.QtMultimedia.QMediaRecorder.setVideoBitRate(bitRate)¶
- Parameters
bitRate – int
Sets the video bitRate
in bits per second.
See also
- PySide6.QtMultimedia.QMediaRecorder.setVideoFrameRate(frameRate)¶
- Parameters
frameRate – float
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.
See also
- PySide6.QtMultimedia.QMediaRecorder.setVideoResolution(width, height)¶
- Parameters
width – int
height – int
Sets the width
and height
of the resolution of the encoded video.
This is an overloaded function.
- PySide6.QtMultimedia.QMediaRecorder.setVideoResolution(arg__1)
- Parameters
arg__1 –
PySide6.QtCore.QSize
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.
See also
- PySide6.QtMultimedia.QMediaRecorder.stop()¶
Stops recording.
The recorder state is changed to StoppedState
.
- PySide6.QtMultimedia.QMediaRecorder.videoBitRate()¶
- Return type
int
Returns the bit rate of the compressed video stream in bits per second.
See also
- PySide6.QtMultimedia.QMediaRecorder.videoBitRateChanged()¶
- PySide6.QtMultimedia.QMediaRecorder.videoFrameRate()¶
- Return type
float
Returns the video frame rate.
See also
- PySide6.QtMultimedia.QMediaRecorder.videoFrameRateChanged()¶
- PySide6.QtMultimedia.QMediaRecorder.videoResolution()¶
- Return type
Returns the resolution of the encoded video.
See also
- PySide6.QtMultimedia.QMediaRecorder.videoResolutionChanged()¶
© 2022 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.