Skip to content
WangBin edited this page Feb 28, 2017 · 8 revisions

How to display a single image

vo->receive(VideoFrame(qt_image));. Main event loop is required to show the image. So if you want to show when startup, you can QTimer::singleShot(0, [=](){vo->receive(VideoFrame(qt_image));});

How to support multiple subtitles

In QML, you can use multiple Subtitle objects and corresponding SubtitleItem, and set property Subtitle.fuzzyMatch to false, Subtitle.file to a subtitle path. C++ app is almost the same, using multiple SubtitleFilter objects and set properties. Actually each QML Subtitle object use an C++ VideoFilter internally.

How to display the first frame and pause

see https://github.com/wang-bin/QtAV/issues/637

    m_player->setStartPosition(1);
connect(m_player, SIGNAL(seekFinished(qint64)), this, SLOT(pauseOnSeek()));
    ...
    void PlayerWindow::pauseOnSeek() {
        m_player->pause(true);
        disconnect(m_player, SIGNAL(seekFinished(qint64)), this, SLOT(pauseOnSeek()));
    }

new VideoOutput() does not work

Since 1.11.0, QtAVWidgets is loaded dynamically in VideoOutput constroctor. All QWidget based renderers are registered when QtAVWidgets module is loaded. On windows, it should work without problem. On linux, you may have to add LD_LIBRARY_PATH including libQtAVWidgets1.so. For static build, you have to use QtAV::Widgets::registerRenderers() manually to ensure QtAVWidgets code is compiled in to your app.

The simplest solution for all is call QtAV::Widgets::registerRenderers() before new VideoOutput()

How to Capture Video Frames

  1. use AVPlayer.videoCapture()->capture()
  2. use VideoFilter installed to AVPlayer
    class CaptureFilter : public VideoFilter
    {
    ...
    protected:
        void process(Statistics* statistics, VideoFrame* frame = 0) override {
            if (!no_capture_was_requested)
                return;
            if (!frame)
                return;
            Q_EMIT captured(frame->toImage());
        }
    };
    ...
    CaptureFilter *f = new CaptureFilter();
    player->installFilter(f);
    ...