Qt6 QML Book/多媒体/视频流

Video Streams

视频流

The VideoOutput element is not limited to be used in combination with a MediaPlayer element. It can also be used with various video sources to display video streams.

VideoOutput元素类型不限于与MediaPlayer元素结合使用。它还可以与各种视频源一起使用,以显示视频流。

For instance, we can use the VideoOutput to display the live video stream of the user's Camera. To do so, we will combine it with two components: Camera and CaptureSession.

例如,我们可以使用VideoOutput来显示用户相机的实时视频流。为此,我们将把它与两个组件结合起来:Camera和CaptureSession。

import QtQuick
import QtMultimedia

Window {
    width: 1024
    height: 768
    visible: true

    CaptureSession {
        id: captureSession
        camera: Camera {}
        videoOutput: output
    }

    VideoOutput {
        id: output
        anchors.fill: parent
    }

    Component.onCompleted: captureSession.camera.start()
}

The CaptureSession component provides a simple way to read a camera stream, capture still images or record videos.

CaptureSession组件提供了一种读取相机流、捕获静止图像或录制视频的简单方法。

As the MediaPlayer component, the CaptureSession element provides a videoOuput attribute. We can thus use this attribute to configure our own visual component.

作为MediaPlayer组件,CaptureSession元素提供了VideoOutput特性。因此,我们可以使用这个特性来配置我们自己的视觉组件。

Finally, when the application is loaded, we can start the camera recording:

最后,当应用程序加载时,我们可以开始摄像机录制:

Component.onCompleted: captureSession.camera.start()

TIP

Depending on your operating system, this application may require sensitive access permission(s). If you run this sample application using the qml binary, those permissions will be requested automatically.

根据您的操作系统,此应用程序可能需要敏感访问权限。如果使用qml二进制文件运行此示例应用程序,将自动请求这些权限。

However, if you run it as an independant program you may need to request those permissions first (e.g.: under MacOS, you would need a dedicated .plist file bundled with your application).

但是,如果您将其作为独立程序运行,则可能需要首先请求这些权限(例如:在MacOS下,您需要一个与应用程序捆绑在一起的专用.plist文件)。

示例源码下载 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在配置QT6的QML环境时,您可以遵循以下步骤: 1. 确保您已经安装了QT6的开发环境。您可以从QT官方网站下载并安装最新版本的QT。 2. 在项目文件(例如myproject.pro)中,添加需要使用的模块。对于QML应用程序,您需要添加QtQuick和QtQml模块到QT变量中,如下所示: ``` QT += qml quick ``` 3. 确保您的项目文件正确指定了源文件。在SOURCES变量中,添加您的main.cpp文件或其他需要编译的源文件,如下所示: ``` SOURCES += main.cpp ``` 4. 使用所选的构建系统来构建您的项目。在QT6中,您可以选择使用CMake作为构建系统。确保设置正确的构建配置和目标平台,并运行构建命令来生成可执行文件。 注意,QT6中不再使用qmake作为默认的构建系统,而是采用了CMake。您可以在项目文件中切换到使用CMake,或者使用QT Creator来配置和构建您的项目。 希望这些信息对您有所帮助!<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [Qt6 QML Book/Qt C++/构建系统](https://blog.csdn.net/aggs1990/article/details/122769759)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值