5

我正在尝试将视频输出(帧序列)到任何 qt 可见小部件。一开始我认为 QLabel 就足够了……但我错了。转换为像素图对于处理大型图像(例如 1080p)来说过于过载。

还有其他解决方案吗?(不是 QLabel?)

一帧的代码示例:

QImage m_outputFrameImage(width, height, QImage::Format_RGB888);
memcpy(m_outputFrameImage.bits(), m_frameRGB->data[0], height * width * 3);
QPixmap pixmap = QPixmap::fromImage(m_outputFrameImage); // BAD, slow and high load
/* Bad too (Same code?)
    QPainter painter;
    painter.begin(&pixmap);
    painter.drawImage(0, 0, m_outputFrameImage);
    painter.end();
*/
labelVideo->setPixmap(pixmap);
4

1 回答 1

5

是的,将帧渲染到 aQGLWidget并让视频卡处理它。这就是 Qt MultimediaKit、Phonon 和其他人的做法。

前段时间我分享了一些代码来演示如何完成这个任务:Image scaling (KeepAspectRatioByExpanding) through OpenGL

于 2012-06-25T18:05:36.360 回答