当前位置: 首页 > wzjs >正文

网站建设做网站需要多少钱商务网站建设ppt

网站建设做网站需要多少钱,商务网站建设ppt,网站开发合同售后服务,网站上放百度地图前言 Qt6提供了更丰富的多媒体支持类,使用Qt6 QMediaCaptureSession、QScreenCapture、QMediaRecorder,来实现一个屏幕录制的demo,其中QScreenCapture 最低版本 Qt6.5。支持录制的清晰度设置,选择视频保存位置,UI使用…

前言

Qt6提供了更丰富的多媒体支持类,使用Qt6 QMediaCaptureSession、QScreenCapture、QMediaRecorder,来实现一个屏幕录制的demo,其中QScreenCapture 最低版本 Qt6.5。支持录制的清晰度设置,选择视频保存位置,UI使用QML来实现。
Qt6还有一个比较好用的类 QWindowCapture, 可以针对窗口录屏。使用静态函数 QList<QCapturableWindow> capturableWindows()
可以获取当前可用的录制窗口,选择窗口进行录制。可以在本demo的基础上进行扩展。

效果图

本demo使用Qt6.8 MinGW进行编译,注意QScreenCapture最低支持Qt6.5,所以版本不能低于6.5.
在这里插入图片描述
在这里插入图片描述

正文

主要使用Qt6 QMediaCaptureSession、QScreenCapture、QMediaRecorder这三个关键的多媒体类来实现。
关键代码:

开始录制和结束录制:

void ScreenRecorder::startRecording()
{if (m_isRecording) {qDebug() << __FUNCTION__ << "Already recording, ignoring request";return;}qDebug() << __FUNCTION__ << "Starting recording process...";// 选择保存文件QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss");QString defaultFileName = QString("%1/ScreenRecording_%2.mp4").arg(defaultPath).arg(timestamp);qDebug() << __FUNCTION__ << "Default save path:" << defaultFileName;QString filePath = QFileDialog::getSaveFileName(nullptr,tr("Save Recording"),defaultFileName,tr("Video Files (*.mp4)"));if (filePath.isEmpty()) {qDebug() << __FUNCTION__ << "User cancelled file selection";m_statusMessage = tr("Recording cancelled");emit statusMessageChanged();return;}qDebug() << __FUNCTION__ << "Selected file path:" << filePath;// 确保目录存在QFileInfo fileInfo(filePath);QDir dir = fileInfo.dir();if (!dir.exists()) {qDebug() << __FUNCTION__ << "Creating directory:" << dir.path();if (!dir.mkpath(".")) {qDebug() << __FUNCTION__ << "Failed to create directory";m_statusMessage = tr("Error: Could not create directory");emit statusMessageChanged();return;}}// 设置输出位置QUrl fileUrl = QUrl::fromLocalFile(filePath);qDebug() << __FUNCTION__ << "Setting output location:" << fileUrl.toString();m_recorder.setOutputLocation(fileUrl);// 更新质量设置updateQualitySettings();// 开始录制qDebug() << __FUNCTION__ << "Starting recorder...";m_recorder.record();// 启动计时器m_elapsedTimer.start();m_timer.start(1000); // 每秒更新一次m_isRecording = true;m_statusMessage = tr("Recording started");emit isRecordingChanged();emit statusMessageChanged();qDebug() << __FUNCTION__ << "Recording started successfully";
}void ScreenRecorder::stopRecording()
{if (!m_isRecording) {return;}qDebug() << __FUNCTION__ << "Stopping recording...";// 获取当前输出位置,用于验证QUrl outputLocation = m_recorder.outputLocation();qDebug() << __FUNCTION__ << "Output location:" << outputLocation.toLocalFile();// 停止录制m_recorder.stop();// 停止计时器m_timer.stop();// 检查文件是否存在QString filePath = outputLocation.toLocalFile();QFileInfo fileInfo(filePath);if (fileInfo.exists()) {qDebug() << __FUNCTION__ << "File saved successfully at:" << filePath;qDebug() << __FUNCTION__ << "File size:" << fileInfo.size() << "bytes";m_statusMessage = tr("Recording saved to %1").arg(filePath);} else {qDebug() << __FUNCTION__ << "Error: File not created at:" << filePath;m_statusMessage = tr("Error: Recording file not created");}m_isRecording = false;emit isRecordingChanged();emit statusMessageChanged();
}

设置录制器:

void ScreenRecorder::setupRecorder()
{qDebug() << __FUNCTION__ << "Setting up recorder...";// 设置捕获会话m_captureSession.setScreenCapture(&m_screenCapture);m_captureSession.setRecorder(&m_recorder);// 设置屏幕捕获m_screenCapture.setScreen(QGuiApplication::primaryScreen());m_screenCapture.setActive(true); // 激活屏幕捕获qDebug() << __FUNCTION__ << "Screen set to:" << QGuiApplication::primaryScreen()->name();qDebug() << __FUNCTION__ << "Screen capture active:" << m_screenCapture.isActive();// 设置录制器QMediaFormat format;format.setFileFormat(QMediaFormat::FileFormat::MPEG4);format.setVideoCodec(QMediaFormat::VideoCodec::H264);// 检查编解码器是否支持QList<QMediaFormat::VideoCodec> supportedCodecs = format.supportedVideoCodecs(QMediaFormat::Encode);qDebug() << __FUNCTION__ << "Supported video codecs:" << supportedCodecs;if (!supportedCodecs.contains(QMediaFormat::VideoCodec::H264)) {qDebug() << __FUNCTION__ << "Warning: H264 codec may not be supported";// 尝试使用第一个可用的编解码器if (!supportedCodecs.isEmpty()) {format.setVideoCodec(supportedCodecs.first());qDebug() << __FUNCTION__ << "Using alternative codec:" << supportedCodecs.first();}}m_recorder.setMediaFormat(format);qDebug() << __FUNCTION__ << "Media format set:" << format.fileFormat() << format.videoCodec();// 应用当前质量设置updateQualitySettings();// 连接信号connect(&m_recorder, &QMediaRecorder::recorderStateChanged,this, &ScreenRecorder::handleRecorderStateChanged);connect(&m_recorder, &QMediaRecorder::errorOccurred,this, &ScreenRecorder::handleError);qDebug() << __FUNCTION__ << "Recorder setup complete";
}

该功能是Qt结合ffmpeg来实现的,运行时会输出相关信息:qt.multimedia.ffmpeg: Using Qt multimedia with FFmpeg version 7.1 LGPL version 2.1 or later
Qt6还提供了很多非常好用的多媒体类,可以实现很多丰富的功能。本文仅演示基础使用,在此demo上可进行更多的扩展。


本文demo下载

http://www.dtcms.com/wzjs/781715.html

相关文章:

  • 咖啡店网站建设模版i18n wordpress
  • 货源网站 源码那种软件可以做视频网站
  • 高端网站建设 引擎技优化方法
  • 住房城乡建设部办公厅网站广告投放平台系统
  • 新乡网站建设找哪家备案的网站名称能重复备案吗
  • 河源建网站本地免费发布信息网站
  • 如何做一个网站赚钱做网站导航
  • 南昌免费做网站做兼职上什么网站
  • 文山网站建设代理家具公司网站模板
  • 公司静态网站模板下载营销公司的营业范围
  • 网站备案的幕布是什么来的多种郑州网站建设
  • 做网站用什么比较好网站地图怎么做XML
  • 大连零基础网站建设教学电话深圳企业推广网站排名
  • 淮安淮阴网站建设wordpress制作婚礼网页
  • 手机网站有免费做的吗企业模式网站列表管理器
  • 三水 网站建设下载一个网站的源码下载
  • 好看的单页面网站模板免费下载怎么创造游戏软件
  • 郑州企业建站策划东莞建网站哪家好
  • 百捷网站建设工资怎样将wordpress导出
  • 英文外贸网站建设无锡常州网络推广
  • 常用的网站推广方法聊大 网站设计
  • 常州做网站要多少钱河北石家庄网站建设
  • 手机在线做ppt的网站有哪些问题wordpress 仿雷锋网
  • 天津网站专业制作杭州网络传媒有限公司
  • 那个网站做生鲜wordpress 查询函数
  • 搜狐网站开发弹幕网站开发代码
  • 济宁专业网站建设最好的做网站的公司
  • 枣庄网站建设哪家强网页广告设计
  • 怎么免费创建自己的网站平台安阳网红打卡地
  • 新做好的网站如何做seo电商网站开发模版