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

做外贸英语要什么网站做网站建设有哪些公司

做外贸英语要什么网站,做网站建设有哪些公司,软件开发文档说明,seo文章代写平台该软件用于切割视频,手动选取视频片段的起始帧和结束帧并保存为json文件。gui界面如下:包含快进、快退、暂停等功能, 代码如下: # codingUTF-8 """ theme: pyqt5实现动作起始帧和结束帧的定位,将定位到…

该软件用于切割视频,手动选取视频片段的起始帧和结束帧并保存为json文件。gui界面如下:包含快进、快退、暂停等功能,

代码如下:

# coding=UTF-8
"""
theme: pyqt5实现动作起始帧和结束帧的定位,将定位到的帧数保存json文件
time:  2024-6-27
author: cong
"""
import json
import re
import sys
from PyQt5.QtMultimedia import QMediaPlayer, QMediaContent, QMediaPlaylist
from PyQt5.QtMultimediaWidgets import QVideoWidget
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *# 使用 QMediaPlayer 可以进行视频文件解码,视频播放必须将视频帧在某个界面组件上显示,
# 有 QVideoWidget 和 QGraphicsVideoItem 两种视频显示组件,也可以从这两个类继承,自定义视频显示组件。
# QMediaPlayer 也可以结合 QMediaPlaylist 实现视频文件列表播放。class VideoWin(QWidget):save_flag = 0save_start_count = 1save_end_count = 2def __init__(self):super(VideoWin, self).__init__()self.setWindowTitle("MediaPlayer")# 播放画面self.player = QMediaPlayer()self.video_widget = QVideoWidget(self)  # 定义视频显示的widget,界面组件self.video_widget.setFixedSize(1280,720)self.player.setVideoOutput(self.video_widget)  # 视频播放输出的widget,就是上面定义的# 当前播放的进度,显示调整视频进度条self.label_time = QLabel()self.timeSlider = QSlider()self.timeSlider.setOrientation(Qt.Horizontal)self.timeSlider.setValue(0)self.timeSlider.setMinimum(0)self.player.positionChanged.connect(self.get_time)self.timeSlider.sliderPressed.connect(self.player.pause)self.timeSlider.sliderMoved.connect(self.change_time)self.timeSlider.sliderReleased.connect(self.player.play)# 打开视频self.open_button = QPushButton('打开')self.open_button.clicked.connect(self.open_file)# 快进self.right_button = QPushButton('快进')self.right_button.clicked.connect(self.up_time)# playself.play_button = QPushButton('播放')self.play_button.clicked.connect(self.player.play)# pauseself.mid_button = QPushButton('暂停')self.mid_button.clicked.connect(self.player.pause)# 快退self.left_button = QPushButton('快退')self.left_button.clicked.connect(self.down_time)# 保存开始时间self.start_button = QPushButton('保存动作开始时间')self.start_button.clicked.connect(self.save_start_time)# 保存结束时间self.end_button = QPushButton('保存动作结束时间')self.end_button.clicked.connect(self.save_end_time)# 所有时间选定,最终保存按钮self.done_button = QPushButton('完成并保存')self.done_button.setFixedSize(100,40)self.done_button.clicked.connect(self.save_json)# 视频路径 entry 布局self.path_entry = QLineEdit()# 创建一个网格布局grid_layout = QGridLayout()self.entry_names = [f'entry_{i + 1}' for i in range(80)]for i in range(80):if (i+1) % 2 == 1:label = QLabel(f"start_frame_d{int((i+1)// 2 + 1)}:")else:label = QLabel(f"end_frame_d{int((i+1) / 2)}:")self.entry_names[i] = QLineEdit(self)grid_layout.addWidget(label, i // 2, (i % 2) * 2)grid_layout.addWidget(self.entry_names[i], i // 2, (i % 2) * 2 + 1)# 上述按钮布局button_layout = QHBoxLayout()button_layout.addWidget(self.open_button)button_layout.addWidget(self.right_button)button_layout.addWidget(self.play_button)button_layout.addWidget(self.mid_button)button_layout.addWidget(self.left_button)button_layout.addWidget(self.start_button)button_layout.addWidget(self.end_button)# 左侧布局left_layout = QVBoxLayout()left_layout.addWidget(self.video_widget)left_layout.addWidget(self.label_time, alignment=Qt.AlignRight)left_layout.addWidget(self.timeSlider)left_layout.addLayout(button_layout)left_layout.addSpacing(100)left_layout.addWidget(QLabel("视频路径:"))left_layout.addWidget(self.path_entry)# 中间布局middle_layout = QVBoxLayout()middle_layout.addLayout(grid_layout)# 右侧布局right_layout = QVBoxLayout()right_layout.addWidget(self.done_button)# 总布局all_layout = QHBoxLayout()all_layout.addLayout(left_layout)all_layout.addLayout(middle_layout)all_layout.addLayout(right_layout)self.setLayout(all_layout)self.showMaximized()# 打开视频def open_file(self):a = QFileDialog.getOpenFileUrl()[0]self.video_path = a.toString()self.player.setMedia(QMediaContent(a))  # 选取视频文件msg = QMessageBox.information(self, '提示', "已经打开视频文件")self.path_entry.setText(self.video_path)# 调节播放进度def change_time(self, num):self.player.setPosition(num)# 快进def up_time(self):# print(self.player.duration())# num = self.player.position() + int(self.player.duration() / 20)num = self.player.position() + 200self.player.setPosition(num)# 快退def down_time(self):# num = self.player.position() - int(self.player.duration() / 20)num = self.player.position() - 200self.player.setPosition(num)# 获取进度条进度def get_time(self, num):self.timeSlider.setMaximum(self.player.duration())self.timeSlider.setValue(num)frame_count = int(num / 1000 * 30)# d = QDateTime.fromMSecsSinceEpoch(num).toString("mm:ss")# print(d)all = self.player.duration()total_count = int(all / 1000 * 30)# all_d = QDateTime.fromMSecsSinceEpoch(all).toString("mm:ss")self.label_time.setText(str(frame_count) + '/' + str(total_count))def closeEvent(self, event):  # 关闭前需要self.player.pause()操作,否则报错self.player.pause()reply = QMessageBox.question(self, '提示',"是否退出",QMessageBox.Yes | QMessageBox.No,QMessageBox.No)if reply == QMessageBox.Yes:event.accept()else:event.ignore()def save_start_time(self):if self.save_flag == 0:self.save_flag = 1start_time = self.player.position()start_frame = int(start_time / 1000 * 30)self.entry_names[self.save_start_count-1].setText(str(start_frame))self.save_start_count += 2QMessageBox.information(self, "保存成功", f"已保存当前时间点:第{start_frame}帧 ")else:QMessageBox.information(self, "保存失败", f"请先保存动作结束时间 ")def save_end_time(self):if self.save_flag == 1:self.save_flag = 0end_time = self.player.position()end_frame = int(end_time / 1000 * 30)self.entry_names[self.save_end_count-1].setText(str(end_frame))self.save_end_count += 2QMessageBox.information(self, "保存成功", f"已保存当前时间点:第{end_frame}帧 ")else:QMessageBox.information(self, "保存失败", f"请先保存动作开始时间 ")def save_json(self):result = {}single_part = {}video_path = self.video_pathprint('当前保存结果来源于视频文件', video_path)result['video_path'] = video_pathresult['split_result'] = []# video_path: 'file:///D:/SplitVideo/dmh2.avi'file_path = re.split('/', video_path)[-1] + '.json'for i in range(len(self.entry_names)):if self.entry_names[i].text() != '':if (i + 1) % 2 == 1:label_key = f"start_frame_d{int((i + 1) // 2 + 1)}:"else:label_key = f"end_frame_d{int((i + 1) / 2)}:"single_part[label_key]= int(self.entry_names[i].text())# print(self.single_part)result['split_result'].append(single_part)with open(file_path, 'w') as f:json.dump(result, f)if __name__ == '__main__':app = QApplication(sys.argv)app.aboutToQuit.connect(app.deleteLater)win = VideoWin()win.show()sys.exit(app.exec())

http://www.15wanjia.com/news/162118.html

相关文章:

  • 台州建设局招标投标网站免费推广方式
  • 福州做网站外包深圳做网站服务公司
  • 模仿一个网站建设多少钱个人可以做电视台网站吗
  • 可以开发哪些网站珠海网站开发维护科技公司
  • 公司网站设计意见如何做外贸品牌网站建设
  • 商品网站开发乌市网站建设为
  • 禅城技术支持骏域网站建设哪家网站雅虎全球购做的好
  • php高性能网站建设免费制作网站的步骤 怎样做网站
  • 龙华做棋牌网站建设哪家公司便宜乡镇网站模板
  • 成都网站建设爱特通专业的购物网站建设
  • 河源市规划建设局网站抖音代运营协议
  • 做实体店打折信息网站精品课程网站建设 碧辉腾乐
  • 怎么做微信小说网站正规seo需要多少钱
  • 个人公司网站模板怎么做网站设计方案
  • 制作网站的分类如何制作微信小程序商城
  • 网站搭建公司加盟大学生ppt自我介绍幻灯片
  • 潍坊网站建设教程对运营网站有什么见解
  • 网站 seo网站付款链接怎么做的
  • 鲁谷网站建设用ps做网站的首页
  • 河南建站网站电子网站怎么做
  • 网站空间免费 优帮云做网站个人怎么赚钱吗
  • 网站html地图怎么做的成都软件外包开发
  • 五合一免费建站江苏建设工程招标网站
  • 平台类网站免费网页设计
  • 京东不让卖网站制作么应用分析网站
  • 东莞清洁服务网站建设建筑工程网页模板
  • 网站建设服务费合同模板网站空间公司
  • 网络整合营销4i原则seo如何快速出排名
  • 网站底部 图标比亚迪新能源汽车秦
  • 在线做交互网站wordpress缓存无法清除