CopperSpice API  1.7.4
Video Overview

CsMultimedia offers both high and low level C++ classes for playing and manipulating video data. Some of these classes also overlap with both camera and audio classes, which can be useful.

Playing Video

You can use the QMediaPlayer class to decode a video file, and display it using QVideoWidget, QGraphicsVideoItem, or a custom class.

The following is an example of how to use QVideoWidget.

player = new QMediaPlayer;
playlist = new QMediaPlaylist(player);
videoWidget = new QVideoWidget;

The following is an example of how to use QGraphicsVideoItem.

player = new QMediaPlayer(this);

Working with Low Level Video Frames

CsMultimedia offers a number of low level classes to make handling video frames a bit easier. These classes are primarily used when writing code that processes video or camera frames. For example, detecting barcodes, or applying a fancy vignette effect, or displaying video in a special way that is otherwise unsupported.

The QVideoFrame class encapsulates a video frame and allows the contents to be mapped into system memory for manipulation or processing, while deriving a class from QAbstractVideoSurface allows you to receive these frames from QMediaPlayer and QCamera.

In order to use myVideoSurface, create an instance of this class and then pass the object to QMediaPlayer::setVideoOutput().

class MyVideoSurface : public QAbstractVideoSurface
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const
// Return the formats you will support
return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_RGB565;
bool present(const QVideoFrame &frame) {
// Handle the frame and do your processing
return true;