1

qt の例のメディア プレーヤーの例を使用しており、カスタム ビデオ サーフェスを作成しようとしています。フレームをリアルタイムで操作して、ガウスフィルターなどの操作を実行できるようにしたいと考えています。ビデオ サーフェスのコードは次のようになります。

QList<QVideoFrame::PixelFormat> VideoSurface::supportedPixelFormats(
        QAbstractVideoBuffer::HandleType handleType) const
{

Q_UNUSED(handleType);

       // Return the formats you will support
       return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_RGB565;
}

bool VideoSurface::present(const QVideoFrame &frame)
    {
        Q_UNUSED(frame);
        // Handle the frame and do your processing
    return true;
}

start 関数を機能させるために実装する必要がありますか? プレーヤーのコードは次のようになります。

    player = new QMediaPlayer(this);
    // owned by PlaylistModel
    playlist = new QMediaPlaylist();
    player->setPlaylist(playlist);

    /*
    QVideoRendererControl* rendererControl = player->service()->requestControl<QVideoRendererControl*>();

    if (rendererControl)
            rendererControl->setSurface(videoSurf);
    else
            qDebug() << "QtVideoSource: Unable to get QVideoRenderControl for video integration. No video will be emitted from this video source.";
    */

//! [create-objs]

    connect(player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64)));
    connect(player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64)));
    connect(player, SIGNAL(metaDataChanged()), SLOT(metaDataChanged()));
    connect(playlist, SIGNAL(currentIndexChanged(int)), SLOT(playlistPositionChanged(int)));
    connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
            this, SLOT(statusChanged(QMediaPlayer::MediaStatus)));
    connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int)));
    connect(player, SIGNAL(videoAvailableChanged(bool)), this, SLOT(videoAvailableChanged(bool)));
    connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage()));


    VideoSurface* videoSurf = new VideoSurface();

    //Don't use video Widget, but the custom video surface
    videoWidget = new VideoWidget(this);

    player->setVideoOutput(videoSurf);

プレーヤーが起動し、オーディオは通常どおりに機能し、タイム カウンターは通常どおりに進みますが、ディスプレイは黒く、ビデオはありません。フレームを表示するにはどうすればよいですか? また、QVideoRendererControl のコメント部分について知りたいです。私はいくつかのサイトからそれを入手しましたが、知りたいのですが、現在の機能の代わりにフレームを操作する別の方法ですか、それとも何に役立ちますか? 前もって感謝します

4

1 に答える 1

0

QAbstractVideoBuffer の代わりに QAbstractVideoSurface を使用するつもりはありませんか? その場合、isFormatSupported および supportedPixelFormats 関数も実装する必要があります。そしてもちろん起動。

于 2015-10-05T16:05:18.197 に答える