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)

シグナル

詳細説明

QVideoFrameInput は、FFmpeg バックエンドでのみサポートされています。

カスタム・ビデオ・フレームは、QVideoFrameInputQMediaRecorderQMediaCaptureSession に接続することで記録できます。プル・モードの実装では、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() を参照してください。

QMediaRecorderQMediaCaptureSessionQVideoSinkも参照のこと

メンバー関数ドキュメント

[explicit] QVideoFrameInput::QVideoFrameInput(QObject *parent = nullptr)

新しい QVideoFrameInput オブジェクトをparent で構築する。

[explicit] QVideoFrameInput::QVideoFrameInput(const QVideoFrameFormat &format, QObject *parent = nullptr)

ビデオフレームformatparent を持つ新しい 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 を一度だけ、またはループ内で、false を返すまで呼び出す。

sendVideoFrame()も参照のこと

bool QVideoFrameInput::sendVideoFrame(const QVideoFrame &frame)

QVideoFrameQMediaRecorder またはQMediaCaptureSession を通してビデオ出力に送る。

指定されたframe が宛先に正常に送信された場合、true を返します。falseインスタンスがQMediaCaptureSession に割り当てられていない場合、セッションにビデオ出力またはメディアレコーダーがない場合、メディアレコーダーが起動していない場合、またはキューが一杯の場合に発生します。信号readyToSendVideoFrame は、送信先が新しいフレームを処理できるようになるとすぐに送信されます。

空のビデオフレームの送信は、QMediaRecorder によって入力ストリームの終了として扱われる。QMediaRecorder::autoStoptrue で、すべての入力がストリームの終了を報告した場合、QMediaRecorder は自動的に録画を停止する。

© 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.