续上文
1.创建输出目录
RESULT_PATH = './res' # 存储录屏和录音的位置
def create_dirs():
if not os.path.exists(RESULT_PATH):
os.mkdir(RESULT_PATH)
video_path = os.path.join(RESULT_PATH, 'video')
sound_path = os.path.join(RESULT_PATH, 'sound')
if not os.path.exists(video_path):
os.mkdir(video_path)
if not os.path.exists(sound_path):
os.mkdir(sound_path)
return video_path, sound_path
2. 按钮中启动录音录屏线程
主要注意一下,暂停和停止的功能实现。
每次暂停都会重新写文件,所以这次添加了将一个目录下所有视频和对应音频转为mp4 -> ts 然后ts合并为mp4 的功能。
class qt_window():
def start_pause(self):
self.start_pressed = not self.start_pressed
if self.start_pressed:
self.button_start_pause.setText('暂停')
now = str(datetime.datetime.now()).split('.')[0]
now =