Skip to content

Commit

Permalink
✨ 间隔改为更直观的倍速
Browse files Browse the repository at this point in the history
  • Loading branch information
Littlefean committed Sep 18, 2024
1 parent 35f3817 commit 6b9180e
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self):
self.is_recording = False # 录制状态
self.capture_interval = 1000 # 默认间隔1000毫秒
self.frame_rate = 30 # 默认帧率
self.speed_rate = 20 # 默认速度倍率

def init_ui(self):
self.setWindowTitle("延时录屏")
Expand All @@ -46,25 +47,26 @@ def init_ui(self):
self.record_button.clicked.connect(self.toggle_recording)
layout.addWidget(self.record_button)

# 添加下拉框选择截屏间隔
layout.addWidget(QLabel("截屏间隔:", self))
self.interval_combo = QComboBox(self)
self.interval_combo.addItems(["0.5s", "1s", "2s", "3s", "5s", "10s"])
self.interval_combo.currentIndexChanged.connect(self.update_interval)
layout.addWidget(self.interval_combo)
layout.addWidget(QLabel("最终视频倍速:", self))
self.speed_combo = QComboBox(self)
self.speed_combo.addItems(["x10", "x20", "x50", "x100", "x200", "x500", "x1000"])
self.speed_combo.currentIndexChanged.connect(self.update_speed)
# 设置默认倍速为20
self.speed_combo.setCurrentIndex(1)
layout.addWidget(self.speed_combo)

# 添加下拉框选择帧率
layout.addWidget(QLabel("帧率:", self))
layout.addWidget(QLabel("最终视频帧率:", self))
self.frame_rate_combo = QComboBox(self)
self.frame_rate_combo.addItems(["30帧", "60帧"])
self.frame_rate_combo.currentIndexChanged.connect(self.update_frame_rate)
layout.addWidget(self.frame_rate_combo)

self.setLayout(layout)

def update_interval(self, index):
intervals = [500, 1000, 2000, 3000, 5000, 10000] # 毫秒数
self.capture_interval = intervals[index]
def update_speed(self, index):
intervals = [10, 20, 50, 100, 200, 500, 1000] # 毫秒数
self.speed_rate = intervals[index]

def update_frame_rate(self, index):
frame_rates = [30, 60] # 帧率选项
Expand Down Expand Up @@ -121,7 +123,7 @@ def start_screenshots(self):
self.grab_screenshot(f"{dir_name}/{self.grab_index}.png")
)
)
self.timer.start(self.capture_interval) # 使用自定义间隔
self.timer.start(int(1000 / self.frame_rate * self.speed_rate)) # 使用自定义间隔

def stop_screenshots(self):
self.is_recording = False
Expand Down

0 comments on commit 6b9180e

Please sign in to comment.