QVideoFrameInput Class
QVideoFrameInput クラスは、QMediaRecorder や、QMediaCaptureSession を通じてビデオ出力にカスタムビデオフレームを提供するために使用されます。詳細...
| ヘッダー: | #include <QVideoFrameInput> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Multimedia) target_link_libraries(mytarget PRIVATE Qt6::Multimedia) |
| qmake: | QT += multimedia |
| 以下のように: | Qt 6.8 |
| 継承元: | QObject |
パブリック関数
| QVideoFrameInput(QObject *parent = nullptr) | |
| QVideoFrameInput(const QVideoFrameFormat &format, QObject *parent = nullptr) | |
| virtual | ~QVideoFrameInput() override |
| QMediaCaptureSession * | captureSession() const |
| QVideoFrameFormat | format() const |
| bool | sendVideoFrame(const QVideoFrame &frame) |
シグナル
| void | readyToSendVideoFrame() |
詳細な説明
QVideoFrameInput は、FFmpeg バックエンドでのみサポートされています。
QVideoFrameInput とQMediaRecorder をQMediaCaptureSession に接続することで、カスタムビデオフレームを記録できます。プルモードで実装する場合は、readyToSendVideoFrame()シグナルに応答してsendVideoFrame()を呼び出します。以下のスニペットでは、このシグナルをカスタムメディアジェネレータクラスのスロットに接続することでこれを実現しています。スロット関数は新しいビデオフレームを含む別のシグナルを発行し、それがsendVideoFrame()に接続されています:
QMediaCaptureSession session;
QMediaRecorder recorder;
QVideoFrameInput videoInput;
session.setRecorder(&recorder);
session.setVideoFrameInput(&videoInput);
MediaGenerator generator; // Custom class providing video frames
connect(&videoInput, &QVideoFrameInput::readyToSendVideoFrame,
&generator, &MediaGenerator::nextVideoFrame);
connect(&generator, &MediaGenerator::videoFrameReady,
&videoInput, &QVideoFrameInput::sendVideoFrame);
recorder.record();以下に、動画フレームを提供するスロット関数の最小限の実装例を示します:
void MediaGenerator::nextVideoFrame()
{
QVideoFrame frame = nextFrame();
emit videoFrameReady(frame);
}詳細については、readyToSendVideoFrame() およびsendVideoFrame() を参照してください。
QMediaRecorder 、QMediaCaptureSession 、およびQVideoSinkも参照してください 。
メンバ関数のドキュメント
[explicit] QVideoFrameInput::QVideoFrameInput(QObject *parent = nullptr)
parent を使用して、新しいQVideoFrameInputオブジェクトを作成します。
[explicit] QVideoFrameInput::QVideoFrameInput(const QVideoFrameFormat &format, QObject *parent = nullptr)
動画フレームformat およびparent を使用して、新しいQVideoFrameInputオブジェクトを構築します。
指定されたformat は、QMediaRecorder::record()を呼び出した際の、対応するビデオエンコーダの初期化におけるヒントとして機能します。フォーマットが指定されていない場合や無効な場合、最初のフレームの送信時にビデオエンコーダが初期化されます。対応するビデオエンコーダの初期化後に、異なるピクセルフォーマットやサイズのビデオフレームを送信すると、録画中のパフォーマンス低下を招く可能性があります。
送信するフレームの種類が事前に分かっている場合は、フォーマットを指定することをお勧めします。
[override virtual noexcept] QVideoFrameInput::~QVideoFrameInput()
そのオブジェクトを破棄します。
QMediaCaptureSession *QVideoFrameInput::captureSession() const
このビデオフレーム入力が接続されているキャプチャセッションを返します。ビデオフレーム入力がキャプチャセッションに接続されていない場合は、nullptr を返します。
QMediaCaptureSession::setVideoFrameInput() を使用して、ビデオフレーム入力をセッションに接続します。
QVideoFrameFormat QVideoFrameInput::format() const
ビデオフレーム入力の生成時に指定されたビデオフレーム形式を返します。
[signal] void QVideoFrameInput::readyToSendVideoFrame()
新しいフレームをビデオフレーム入力に送信できることを示す信号です。この信号を受信した後、送信すべきフレームがある場合は、sendVideoFrame を 1 回、またはループ内で、false が返されるまで呼び出してください。
sendVideoFrame()も参照してください 。
bool QVideoFrameInput::sendVideoFrame(const QVideoFrame &frame)
QVideoFrame をQMediaRecorder に送信するか、QMediaCaptureSession を通じてビデオ出力を送信します。
指定されたframe が宛先に正常に送信された場合、true を返します。 フレームが送信されなかった場合、false を返します。これは、インスタンスがQMediaCaptureSession に割り当てられていない場合、セッションにビデオ出力やメディアレコーダーがない場合、メディアレコーダーが起動されていない場合、またはそのキューが満杯の場合に発生する可能性があります。宛先が新しいフレームを処理できるようになるとすぐに、readyToSendVideoFrame シグナルが送信されます。
空のビデオフレームの送信は、QMediaRecorder によって入力ストリームの終了として扱われます。QMediaRecorder は、QMediaRecorder::autoStop がtrue であり、かつすべての入力がストリームの終了を報告した場合、自動的に録画を停止します。
© 2026 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.