QMediaCaptureSession Class
QMediaCaptureSession 类允许捕获音频和视频内容。更多
头文件: | #include <QMediaCaptureSession> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Multimedia) target_link_libraries(mytarget PRIVATE Qt6::Multimedia) |
qmake: | QT += multimedia |
在 QML 中: | CaptureSession |
继承: | QObject |
属性
|
|
公共功能
QMediaCaptureSession(QObject *parent = nullptr) | |
virtual | ~QMediaCaptureSession() override |
QAudioBufferInput * | audioBufferInput() const |
QAudioInput * | audioInput() const |
QAudioOutput * | audioOutput() const |
QCamera * | camera() const |
QImageCapture * | imageCapture() |
QMediaRecorder * | recorder() |
QScreenCapture * | screenCapture() |
void | setAudioBufferInput(QAudioBufferInput *input) |
void | setAudioInput(QAudioInput *input) |
void | setAudioOutput(QAudioOutput *output) |
void | setCamera(QCamera *camera) |
void | setImageCapture(QImageCapture *imageCapture) |
void | setRecorder(QMediaRecorder *recorder) |
void | setScreenCapture(QScreenCapture *screenCapture) |
void | setVideoFrameInput(QVideoFrameInput *input) |
void | setVideoOutput(QObject *output) |
void | setVideoSink(QVideoSink *sink) |
void | setWindowCapture(QWindowCapture *windowCapture) |
QVideoFrameInput * | videoFrameInput() const |
QObject * | videoOutput() const |
QVideoSink * | videoSink() const |
QWindowCapture * | windowCapture() |
信号
void | audioBufferInputChanged() |
void | audioInputChanged() |
void | audioOutputChanged() |
void | cameraChanged() |
void | imageCaptureChanged() |
void | recorderChanged() |
void | screenCaptureChanged() |
void | videoFrameInputChanged() |
void | videoOutputChanged() |
void | windowCaptureChanged() |
详细说明
QMediaCaptureSession 是管理本地设备上媒体捕获的中心类。
您可以使用setCamera(),setScreenCapture(),setWindowCapture() 或setVideoFrameInput() 将视频输入连接到 QMediaCaptureSession。通过使用setVideoOutput() 设置QVideoWidget 或QGraphicsVideoItem ,可以预览捕获的媒体。
您可以使用setAudioInput() 将麦克风连接到 QMediaCaptureSession,或使用setAudioBufferInput() 设置自定义音频输入。使用setAudioOutput() 将音频路由到输出设备,就能听到捕捉到的声音。
通过在捕获会话上设置QImageCapture 对象,可以从摄像头捕获静态图像,还可以使用QMediaRecorder 录制音频/视频。
另请参阅 QCamera,QAudioDevice,QMediaRecorder,QImageCapture,QScreenCapture,QWindowCapture,QVideoFrameInput,QMediaRecorder 和QGraphicsVideoItem 。
属性文档
[since 6.8]
audioBufferInput : QAudioBufferInput*
此属性保存用于向QMediaRecorder 发送自定义音频缓冲区的对象。
此属性在 Qt 6.8 中引入。
访问函数:
QAudioBufferInput * | audioBufferInput() const |
void | setAudioBufferInput(QAudioBufferInput *input) |
Notifier 信号:
void | audioBufferInputChanged() |
audioInput : QAudioInput*
返回用于采集音频的设备。
访问功能:
QAudioInput * | audioInput() const |
void | setAudioInput(QAudioInput *input) |
Notifier 信号:
void | audioInputChanged() |
audioOutput : QAudioOutput*
返回会话的音频输出。
访问功能:
QAudioOutput * | audioOutput() const |
void | setAudioOutput(QAudioOutput *output) |
Notifier 信号:
void | audioOutputChanged() |
camera : QCamera*
该属性包含用于捕捉视频的摄像头。
使用此属性将摄像机添加到捕捉会话中,即可录制视频或拍摄图像。
访问功能:
QCamera * | camera() const |
void | setCamera(QCamera *camera) |
通知信号:
void | cameraChanged() |
imageCapture : QImageCapture*
该属性包含用于捕捉静态图像的对象。
将QImageCapture 对象添加到捕获会话中可从摄像机捕获静态图像。
访问功能:
QImageCapture * | imageCapture() |
void | setImageCapture(QImageCapture *imageCapture) |
通知信号:
void | imageCaptureChanged() |
recorder : QMediaRecorder*
该属性包含用于捕获音频/视频的记录器对象。
在捕获会话中添加QMediaRecorder 对象,可从捕获会话中录制音频和/或视频。
访问功能:
QMediaRecorder * | recorder() |
void | setRecorder(QMediaRecorder *recorder) |
通知信号:
void | recorderChanged() |
[since 6.5]
screenCapture : QScreenCapture*
该属性包含用于捕捉屏幕的对象。
使用此属性将屏幕捕获对象添加到捕获会话中,即可记录屏幕。
此属性在 Qt 6.5 中引入。
访问函数:
QScreenCapture * | screenCapture() |
void | setScreenCapture(QScreenCapture *screenCapture) |
Notifier 信号:
void | screenCaptureChanged() |
[since 6.8]
videoFrameInput : QVideoFrameInput*
该属性包含用于向QMediaRecorder 或视频输出发送自定义视频帧的对象。
此属性在 Qt 6.8 中引入。
访问函数:
QVideoFrameInput * | videoFrameInput() const |
void | setVideoFrameInput(QVideoFrameInput *input) |
Notifier 信号:
void | videoFrameInputChanged() |
videoOutput : QObject*
返回会话的视频输出。
访问功能:
QObject * | videoOutput() const |
void | setVideoOutput(QObject *output) |
通知信号:
void | videoOutputChanged() |
[since 6.6]
windowCapture : QWindowCapture*
该属性包含用于捕捉窗口的对象。
使用此属性将窗口捕获对象添加到捕获会话中,即可记录窗口。
此属性在 Qt 6.6 中引入。
访问函数:
QWindowCapture * | windowCapture() |
void | setWindowCapture(QWindowCapture *windowCapture) |
Notifier 信号:
void | windowCaptureChanged() |
成员函数文档
[explicit]
QMediaCaptureSession::QMediaCaptureSession(QObject *parent = nullptr)
从parent 对象创建媒体捕获会话。
[override virtual noexcept]
QMediaCaptureSession::~QMediaCaptureSession()
销毁会话。
void QMediaCaptureSession::setAudioInput(QAudioInput *input)
将音频输入设备设置为input 。如果设置为空QAudioDevice ,捕获会话将使用操作系统定义的默认输入。
注: 属性audioInput 的设置函数。
另请参阅 audioInput() 。
void QMediaCaptureSession::setAudioOutput(QAudioOutput *output)
将音频输出设备设置为output 。
设置音频输出设备可从音频输入设备进行音频路由。
注: 属性audioOutput 的设置函数。
另请参阅 audioOutput() 。
void QMediaCaptureSession::setVideoOutput(QObject *output)
将QObject, (output) 设置为捕获会话的视频预览。
基于QObject 的预览预计会有一个可调用的videoSink() 方法,该方法会返回一个QVideoSink 。
先前设置的预览将被分离。
注: 属性videoOutput 的设置函数。
另请参阅 videoOutput()。
void QMediaCaptureSession::setVideoSink(QVideoSink *sink)
将QVideoSink, (sink) 设置为捕获会话的视频预览。
基于QObject 的预览预计会有一个可调用的videoSink() 方法,该方法会返回一个QVideoSink 。
之前设置的预览会被分离。
另请参阅 videoSink() 。
QVideoSink *QMediaCaptureSession::videoSink() const
返回会话的QVideoSink 。
另请参阅 setVideoSink().
© 2025 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.