How to grab video frames in Qt?

后端 未结 2 882
南旧
南旧 2020-12-11 03:21

I am new to Qt, I only know the basics: create interfaces and connect slots. In a few words, my knowledge is not deep at all.

I need to open a video file and captur

2条回答
  •  [愿得一人]
    2020-12-11 04:00

    You can use QMediaPlayer to achieve this.

    1. Instantiate the QMediaPlayer.
    2. Subclass the QAbstractVideoSurface.
    3. Set your implementation as the output for the media player via QMediaPlayer::setVideoOutput.
    4. Feed the media player the needed file and eventually it will start calling QAbstractVideoSurface::present(const QVideoFrame & frame) on your implementation of QAbstractVideoSurface if the video was loaded successfully. Then you can access the channels and everything from the QVideoFrame and draw the frame on a widget.

提交回复
热议问题