1. Environmental introduction
Operating system: win10 64 bit
QT version: QT5.12.6
Compiler: MinGW 32
QtAV version: QtAV-1.12.0
FFMPEG version : ffmpeg 3.1 uses the package provided by QtAV, use it directly
Two, QTAV compilation and installation process
Reference blog: https://blog.csdn.net/xiaolong1126626497/article/details/112209279
Three, get the image data of each frame of the decoded video
Idea: Inherit VideoOutput and re-implement the receiveFrame function.
#include <QObject>
#include <QWidget>
#include <VideoOutput.h>
#include <QDebug>
using namespace QtAV;
class my_qtav_videoOut: public VideoOutput
{
Q_OBJECT
public:
my_qtav_videoOut(QObject *parent = nullptr);
signals:
void SendOneFrame(QImage img);
protected:
//接收帧
bool receiveFrame(const VideoFrame& frame);
};
my_qtav_videoOut::my_qtav_videoOut(QObject *parent)
{
}
//接收帧
bool my_qtav_videoOut::receiveFrame(const VideoFrame& frame)
{
//得到每帧的图像
QImage Image=frame.toImage();
//将得到的一帧数据传递出去
emit SendOneFrame(Image);
return true;
}
How to use:
my_qtav_videoOut *m_vo;
AVPlayer *m_player;
Widgets::registerRenderers();
m_player = new AVPlayer(this);
m_vo=new my_qtav_videoOut(this);
m_player->setRenderer(m_vo);
//关联播放器的视频帧显示
connect(m_vo, SIGNAL(SendOneFrame(QImage)),ui->widget,SLOT(slotGetOneFrame(QImage)));