QML Video Recorder

Recording audio and video using Qt Quick.

QML Recorder demonstrates a simple application that can record audio and video separate or together, using a microphone, a camera.

Running the Example

To run the example from Qt Creator, open the Welcome mode and select the example from Examples. For more information, visit Building and Running an Example.

Overview

At its core, this is a QML application, see Getting Started Programming with Qt Quick. This documentation is focused on how this example uses the Qt Multimedia QML types.

The example uses the QML Camera and AudioInput types connected to a CaptureSession. A MediaRecorder object is then used to record the captured audio and video.

In addition to QtMultimedia, features of Qt Quick Windows, Controls, and Layouts are used to implement the graphic user interface and functionality. Playback won't be covered here, for that see the QML Media Player Example.

The example demonstrates the following:

  • Input devices can be selected.
  • An input type switched off.
  • Settings for capturing such as quality, codec choice, file format, and assigning metadata.
  • Captured files are stored and can be played back.

Recording

The application implements recording.

captureSession

In main.qml, captureSession is declared like so:

recorder

In main.qml, the MediaRecorder recorder handles recording media as well as capturing a thumbnail for the file and appending it to a ListModel, mediaList.

mediaList is declared in the Frame mediaListFrame

controls

These are defined in Controls.qml and declared in main.qml.

Its root is a Row that contains the Columns inputControls, recordButton, optionButtons, each defined in their own .qml files.

Selecting a video source

Defined in VideoSourceSelect.qml, VideoSourceSlect is comprised of a Switch and a ComboBox and enables the user to select from available cameras.

comboBox, declared in the above snippet, assigns the current video source.

Selecting an audio input

Implemented in the same way as Selecting a camera and defined in AudioInputSelect.qml like so:

Example project @ code.qt.io

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.