Qt多媒体

Qt Multimedia

Qt多媒体

Qt Multimedia is an add-on module that provides a rich set of QML types and C++ classes to handle multimedia content. It contains an easy to use API for playing back audio and video files and rendering those on screen, as well as a comprehensive API for recording audio and video from the system's cameras and microphones.

Qt Multimedia是一个附加模块,它提供了一组丰富的QML类型和C++类来处理多媒体内容。它包含一个易于使用的API,用于回放音频和视频文件并在屏幕上渲染这些文件,以及一个全面的API,可用于从系统的摄像头和麦克风录制音频和视频。

The functionality of this module is divided into the following submodules:

本模块的功能分为以下子模块:

Qt Multimedia

Provides an API for multimedia-specific use cases.

为多媒体特定用例提供API。

Qt Multimedia Widgets

Provides a widget-based multimedia API.

提供基于widget的多媒体API。

Qt Spatial Audio

(Technology Preview) Provides an API for implementing sound fields in 3D space.

(技术预览)提供用于在3D空间中实现声场的API。

Getting started

新手入门

If you are porting from Qt 5 to Qt 6 see Changes to Qt Multimedia.

​如果要从Qt 5移植到Qt 6,请参阅更改Qt多媒体。

If you are new to Qt Multimedia, the QML types can be imported into an application using the following statement in your .qml file.

​如果您是Qt Multimedia的新手,可以使用.QML文件中的以下语句将QML类型导入到应用程序中。

import QtMultimedia

To link against the C++ libraries, add the following to your project's CMakeLists.txt file. Substitute my_project with the name of your project.

要链接到C++库,请将以下内容添加到项目的CMakeLists.txt文件中。用项目名称替换my_project。

find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(my_project PRIVATE Qt6::Multimedia)

Overviews and Important Topics

概述和重要议题

QML Types

QML类型

The following table outlines some important QML types.

下表概述了一些重要的QML类型。

Type

类型

Description

描述

MediaPlayer

Add audio/video playback functionality to a scene.

向场景添加音频/视频播放功能。

CaptureSession

Create a session for capturing audio/video.

创建用于捕获音频/视频的会话。

Camera

Access a camera connected to the system.

访问连接到系统的摄像头。

AudioInput

Access an audio input (microphone) connected to the system.

访问连接到系统的音频输入(麦克风)。

AudioOutput

Access an audio output (speaker, headphone) connected to the system.

访问连接到系统的音频输出(扬声器、耳机)。

VideoOutput

Display video content.

显示视频内容。

MediaRecorder

Record audio/video from the CaptureSession.

​从CaptureSession录制音频/视频。

ImageCapture

Capture still images from the Camera.

从相机拍摄静态图像。

Video

Add Video playback functionality to a scene. Uses MediaPlayer and VideoOutput types to provide video playback functionality.

​向场景添加视频播放功能。使用MediaPlayer和VideoOutput类型提供视频播放功能。

C++ Classes

C++类

The following table outlines some important C++ Classes

下表概述了一些重要的C++类

Class

Description

描述

QMediaPlayer

Playback media from a source.

从源播放媒体。

QVideoWidget

Display video from a media player or a capture session.

显示媒体播放器或捕获会话中的视频。

QMediaCaptureSession

Capture audio and video.

捕获音频和视频。

QCamera

Access a camera connected to the system

访问连接到系统的摄像头

QAudioInput

Access an audio input (microphone) connected to the system.

访问连接到系统的音频输入(麦克风)。

QAudioOutput

Access an audio output (speaker, headphone) connected to the system.

访问连接到系统的音频输出(扬声器、耳机)。

QImageCapture

Capture still images with a camera.

使用相机拍摄静态图像。

QMediaRecorder

Record media content from a capture session.

记录捕获会话中的媒体内容。

QVideoSink

Access and render individual video frames.

访问和渲染单个视频帧。

QAudioSink

Sends raw audio data to an audio output device.

将原始音频数据发送到音频输出设备。

For playback QMediaPlayerQAudioOutput and QVideoOutput contain all the required functionality. The other classes are used for capturing audio and video content, where the QMediaCaptureSession is the central class managing the whole capture/recording process.

​对于播放QMediaPlayer,QAudioOutput和QVideoOutput包含所有必需的功能。其他类用于捕获音频和视频内容,其中QMediaCaptureSession是管理整个捕获/录制过程的中心类。

Licenses and Attributions

许可证和属性

The Qt Multimedia module is available under commercial licenses from The Qt Company. In addition, it is available under free software licenses. Since Qt 5.6, these free software licenses are GNU Lesser General Public License, version 3, or the GNU General Public License, version 2. See Qt Licensing for further details.

​Qt多媒体模块根据Qt公司的商业许可证提供。此外,它还具有免费软件许可证。由于Qt 5.6,这些自由软件许可证是GNU Lesser General Public License(第3版)或GNU General Puplic Licence(第2版)。有关更多详细信息,请参阅Qt Licensing。

The FFmpeg backend uses the FFmpeg framework. FFmpeg is licensed under LGPLv2.1, GPLv2, or later versions of the licenses. Some optional components of FFmpeg are only available under GPL. The FFmpeg backend shipped with the Qt binary packages is configured to not contain any of the components that are available under GPLv2 only. See the FFmpeg licensing page for further details.

​FFmpeg后端使用FFmpeg-框架。FFmpeg是在LGPLv2.1、GPLv2或更高版本的许可证下许可的。FFmpeg的一些可选组件仅在GPL下可用。Qt二进制软件包附带的FFmpeg后端配置为不包含任何仅在GPLv2下可用的组件。有关更多详细信息,请参阅FFmpeg许可页面。

Target platform and backend notes

目标平台和后端说明

On most platforms, there are two different backends that can be used for Qt Multimedia.

在大多数平台上,有两种不同的后端可用于Qt Multimedia。

The first one is the backend built on the native multimedia framework of the underlying operating system. This is currently the default, and will use gstreamer on Linux, AVFoundation on macOS/iOS, WMF on Windows, and the MediaCodec framework on Android.

第一个是构建在底层操作系统的本机多媒体框架上的后端。这是当前的默认设置,将在Linux上使用gstreamer,在macOS/iOS上使用AVFoundation,在Windows上使用WMF,在Android上使用MediaCodec框架。

While we try to support our full API on all backends using the native multimedia framework, platform specific limitations do exist in a few places. This is due to the fact that the feature set supported by those frameworks varies, implying that some functionality might not be available on all platforms. This is especially true for the set of supported file formats and codecs, as well as advanced camera functionality.

虽然我们试图使用本机多媒体框架在所有后端上支持我们的完整API,但在一些地方确实存在特定于平台的限制。这是因为这些框架支持的功能集各不相同,这意味着某些功能可能并非在所有平台上都可用。这对于一组受支持的文件格式和编解码器以及高级相机功能来说尤其如此。

Where limitations exist, we aim to document those in the respective classes and methods.

如果存在限制,我们将在各自的类和方法中记录这些限制。

With Qt 6.4, we are adding a new, more platform independent backend based on the FFmpeg framework. The FFmpeg backend is currently available as a technology preview. This backend has the advantage that we can offer proper cross-platform support for all features of Qt Multimedia, going beyond the limitations that exist with many of the native frameworks.

​在Qt 6.4中,我们添加了一个基于FFmpeg框架的新的、更独立于平台的后端。FFmpeg后端目前作为技术预览版提供。此后端的优点是,我们可以为Qt Multimedia的所有功能提供适当的跨平台支持,超越了许多本机框架的限制。

You can test the FFmpeg backend right now by using a Qt build that has FFmpeg enabled and setting the QT_MEDIA_BACKEND environment variable to ffmpeg:

现在可以通过使用启用了FFmpeg的Qt构建并将QT_MEDIA_BACKEND环境变量设置为ffmpeg:

export QT_MEDIA_BACKEND=ffmpeg

Reference and Examples

参考和示例

© 2022 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.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值