#include <QtVideoRecorder.h>
Signals | |
| void | recordingChanged (bool recording) |
| void | recordingStarted (const QString &file) |
| void | recordingFinished (const QString &file, const QString &error) |
error is empty for a recording that finished normally. | |
Public Member Functions | |
| QtVideoRecorder (QObject *parent=nullptr) | |
| ~QtVideoRecorder () override | |
| QMediaRecorder * | mediaRecorder () const |
| bool | recording () const |
| From the first encoded frame until the recorder stops. | |
| bool | active () const |
| Recording, or waiting for the first frame to encode. | |
| void | start (const QString &file, QMediaFormat::FileFormat container, QMediaFormat::VideoCodec codec=QMediaFormat::VideoCodec::Unspecified, QMediaRecorder::Quality quality=QMediaRecorder::HighQuality) |
| void | stop () |
| void | stopAndWait (std::chrono::milliseconds timeout=kFinishTimeout) |
Static Public Member Functions | |
| static QList< QMediaFormat > | recordingFormats (QMediaFormat::FileFormat container, QMediaFormat::VideoCodec codec=QMediaFormat::VideoCodec::Unspecified) |
| static QStringList | recordingCodecs () |
| static QMediaFormat::VideoCodec | recordingCodec (const QString &key) |
The codec of key key, as recordingCodecs() names it; Unspecified for an empty or unknown key. | |
| static QString | recordingCodecName (const QString &key) |
The name of the codec of key key, such as "H.264", for display. | |
| static QMediaFormat::FileFormat | container (VideoReceiver::FileFormat format) |
The container of format. | |
| static QMediaRecorder::Quality | recordingQuality (int value) |
The quality of value value, one of VideoSettings::uvcRecordingQuality's; HighQuality for any other. | |
Static Public Attributes | |
| static constexpr std::chrono::seconds | kFinishTimeout {5} |
| How long an owner going away waits for a recording's file to be finished. | |
Friends | |
| class | QtVideoRecorderTest |
Records the video of a QMediaCaptureSession with Qt Multimedia's encoders: a USB camera's (UVCCameraController), or a stream's decoded frames fed in through a QVideoFrameInput (QtMultimediaVideoReceiver). The capture session records with mediaRecorder(), which outlives it: a session going away mid-recording makes it finish the file and report it.
start() records to "<file without suffix>.<suffix of the format used>", at the quality asked for, trying recordingFormats() in turn until one encodes. recordingStarted() follows once the first frame is encoded, or recordingFinished() with an error; a failed attempt leaves no file behind. Recordings carry their start time and VideoReceiver::recordingComment().
Definition at line 22 of file QtVideoRecorder.h.
|
explicit |
Definition at line 64 of file QtVideoRecorder.cc.
References recordingChanged(), and recordingStarted().
|
overridedefault |
|
inline |
Recording, or waiting for the first frame to encode.
Definition at line 41 of file QtVideoRecorder.h.
|
static |
The container of format.
Definition at line 155 of file QtVideoRecorder.cc.
References VideoReceiver::Mkv, VideoReceiver::Mov, and VideoReceiver::Mp4.
Referenced by QtMultimediaVideoReceiver::onStartRecording(), UVCCameraController::onStartRecording(), recordingCodecs(), recordingFormats(), and start().
|
inline |
Definition at line 35 of file QtVideoRecorder.h.
|
inline |
From the first encoded frame until the recorder stops.
Definition at line 38 of file QtVideoRecorder.h.
Referenced by recordingChanged(), and stopAndWait().
|
signal |
References recording().
Referenced by QtMultimediaVideoReceiver::QtMultimediaVideoReceiver(), QtVideoRecorder(), stopAndWait(), and UVCCameraController::UVCCameraController().
|
static |
The codec of key key, as recordingCodecs() names it; Unspecified for an empty or unknown key.
Definition at line 143 of file QtVideoRecorder.cc.
Referenced by recordingCodecName().
|
static |
The name of the codec of key key, such as "H.264", for display.
Definition at line 150 of file QtVideoRecorder.cc.
References recordingCodec().
Referenced by UVCCameraController::recordingCodecName().
|
static |
The codecs Qt can encode a recording in here, in any of the recording containers, as the keys of QMediaFormat::VideoCodec (such as "H264"): the values of VideoSettings::uvcRecordingCodec. recordingFormats()'s fallbacks come first, in its order.
Definition at line 120 of file QtVideoRecorder.cc.
References container().
Referenced by UVCCameraController::recordingCodecs().
|
signal |
error is empty for a recording that finished normally.
Referenced by QtMultimediaVideoReceiver::QtMultimediaVideoReceiver(), start(), and UVCCameraController::UVCCameraController().
|
static |
The formats start() tries for container, best first: codec where Qt can encode it, then H.264 and the other codecs Qt can encode here, down to software MPEG-2. In container where Qt can write it, else in another container. Qt counts a hardware encoder as encodable even where the hardware turns it down, hence the fallbacks.
Definition at line 83 of file QtVideoRecorder.cc.
References container().
Referenced by start().
|
static |
The quality of value value, one of VideoSettings::uvcRecordingQuality's; HighQuality for any other.
Definition at line 168 of file QtVideoRecorder.cc.
|
signal |
| void QtVideoRecorder::start | ( | const QString & | file, |
| QMediaFormat::FileFormat | container, | ||
| QMediaFormat::VideoCodec | codec = QMediaFormat::VideoCodec::Unspecified, | ||
| QMediaRecorder::Quality | quality = QMediaRecorder::HighQuality ) |
Records the capture session mediaRecorder() is set on to file, in container and codec where Qt can encode them: see recordingFormats(). quality sets how large the file gets: Qt encodes for a constant quality, or for a bit rate it works out from one where the encoder takes only that (Android, iOS, Intel Macs). Reports recordingFinished() with an error when no format encodes.
Definition at line 174 of file QtVideoRecorder.cc.
References container(), recordingFinished(), and recordingFormats().
| void QtVideoRecorder::stop | ( | ) |
Definition at line 219 of file QtVideoRecorder.cc.
Referenced by stopAndWait().
| void QtVideoRecorder::stopAndWait | ( | std::chrono::milliseconds | timeout = kFinishTimeout | ) |
Stops recording and waits up to timeout for the file to be finished: Qt writes it on its own thread, which the application's exit would cut short.
Definition at line 225 of file QtVideoRecorder.cc.
References recording(), recordingChanged(), and stop().
|
friend |
Definition at line 26 of file QtVideoRecorder.h.
References QtVideoRecorderTest.
Referenced by QtVideoRecorderTest.
|
staticconstexpr |
How long an owner going away waits for a recording's file to be finished.
Definition at line 30 of file QtVideoRecorder.h.