├── .gitignore
├── DevicesInfo.py
├── README.md
├── RecordConfig.py
├── RecordHelp.py
├── RecordTrayIcon.py
├── RecordType.py
├── RecordVideo.py
├── RecordWindow.py
├── RunCMD.py
├── SettingWindow.py
├── Shortcut.py
├── complex_setup.py
├── csetup.py
├── ffmpeg-shared
├── LICENSE.txt
├── README.txt
├── bin
│ ├── avcodec-58.dll
│ ├── avdevice-58.dll
│ ├── avfilter-7.dll
│ ├── avformat-58.dll
│ ├── avutil-56.dll
│ ├── ffmpeg.exe
│ ├── ffplay.exe
│ ├── ffprobe.exe
│ ├── postproc-55.dll
│ ├── swresample-3.dll
│ └── swscale-5.dll
└── presets
│ ├── ffprobe.xsd
│ ├── libvpx-1080p.ffpreset
│ ├── libvpx-1080p50_60.ffpreset
│ ├── libvpx-360p.ffpreset
│ ├── libvpx-720p.ffpreset
│ └── libvpx-720p50_60.ffpreset
├── list_devices_exarct.py
├── requirements.txt
├── resource.py
├── resource.qrc
├── resource
├── camera_recording.png
├── camera_recording_colorful.png
├── camera_recording_yellow.png
├── gutin.ico
├── gutin.jpg
├── screen_black.png
├── screen_recording.png
├── start.png
├── start_black.png
├── stop.png
└── stop_black.png
├── setup.iss
└── test
├── help.html
└── read_winreg.py
/.gitignore:
--------------------------------------------------------------------------------
1 | *.7z
2 | *.mkv
3 | *.mp4
4 | config.ini
5 | configByLinxiao.ini
6 | log.txt
7 | log_cmd.txt
8 | think.txt
9 | __pycache__
10 | dist
11 | build
12 | zongjie.txt
13 |
14 |
--------------------------------------------------------------------------------
/DevicesInfo.py:
--------------------------------------------------------------------------------
1 | import re
2 | import RunCMD
3 | from RunCMD import run_cmd
4 | import cchardet
5 | import logging
6 |
7 | class DevicesInfo():
8 |
9 | def __init__(self):
10 |
11 | #日志
12 | self.logger = logging.getLogger(__name__)
13 | self.logger.setLevel(level = logging.INFO)
14 | handler = logging.FileHandler('log.txt')
15 | handler.setLevel(logging.INFO)
16 | formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
17 | handler.setFormatter(formatter)
18 |
19 | self.logger.addHandler(handler)
20 |
21 | list_devices_cmd = 'ffmpeg -list_devices true -f dshow -i dummy'
22 | # status, output = subprocess.getstatusoutput(list_devices_cmd)
23 | output_err, output_str = run_cmd(list_devices_cmd, universal_newlines = False)
24 | self.video_devices , self.voice_devices = self.extract_devices_info(output_err)
25 |
26 | def get_device_info(self, text_list):
27 | device_list = []
28 | if text_list and len(text_list) % 2 == 0:
29 | i=0
30 | while i < len(text_list):
31 | step = 2
32 | device = []
33 | device_name = text_list[i].strip()
34 | device.append(device_name.replace('"',''))
35 | alternative_name_text = text_list[i+1]
36 | alter_re = re.search(r'"(.+)"',alternative_name_text)
37 | if alter_re:
38 | device_alternative_name = alter_re.group(1)
39 | device.append(device_alternative_name)
40 | device_list.append(device)
41 | i+=step
42 | return device_list
43 |
44 | def extract_devices_info(self,devices_output):
45 | device_line = []
46 | devices_output_copy = devices_output[0:]
47 | devices_txt = ''
48 | self.logger.info('devices_text:')
49 | for txt in devices_output_copy:
50 | # charset = cchardet.detect(txt)
51 | # if charset
52 | self.logger.info(txt)
53 | devices_txt += txt.decode('utf-8').replace(r'\r\n','')
54 | # print(dir(re))
55 | self.logger.info('decode result:')
56 | self.logger.info(devices_txt)
57 | print(devices_txt)
58 | results = re.findall(r'\[[^\]]+\]([^\[]+)',devices_txt)
59 | # results.pop(0)
60 | video_devices_spos=-1
61 | voice_devices_spos=-1
62 | for i in range(len(results)):
63 | txt = results[i]
64 | # print(txt.strip())
65 | if txt.find('DirectShow video devices') >= 0:
66 | video_devices_spos = i
67 | if txt.find('DirectShow audio devices') >=0:
68 | voice_devices_spos = i
69 |
70 | video_devices = self.get_device_info(results[video_devices_spos+1:voice_devices_spos])
71 | voice_devices = self.get_device_info(results[voice_devices_spos+1:])
72 |
73 | return video_devices , voice_devices
74 |
75 | # if __name__ == '__main__':
76 | # di = DevicesInfo()
77 | # print('视频设备列表:\n%s' % di.video_devices)
78 | # print('音频设备列表:\n%s' % di.voice_devices)
79 | # print('音频设备列表:')
80 | # for device in di.voice_devices:
81 | # item = device[0]
82 | # print(item.encode('utf-8').decode('gb2312'))
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # 使用Python3基于FFmpeg实现的录制摄像头和屏幕录制
3 | ## 1. 项目介绍
4 | 该项目是为珠海一家音频技术公司开发的会议视频录制管理工具。客户需求使用的场景是在会议室开会时切换录制电脑屏幕和摄像头的内容。项目采用python3语言+pyqt5界面实现,录制模块基于ffmpeg项目,在win系列系统上稳定运行。
5 |
6 | #### 系统主要模块及描述:
7 | 1. **主界面。** 主界面显示录制时间和开始/停止按钮展示录制状态,为了尽可能少的出现在录制内容当中,界面在失去焦点时会隐藏。
8 |
9 | 2. **全局快捷键。** 自定义全局快捷键控制录制开始与停止、切换录制方式。
10 |
11 | 3. **托盘图标。** 程序在运行的大部分时间通过托盘图标来展示当前录制状态,不同录制状态分别以不同的图标显示。
12 |
13 | 4. **右键菜单。** 当主界面隐藏时,除使用全局快捷键切换录制,还可以通过托盘图标和主界面的右键菜单操作。
14 |
15 | 5. **自定义设置。** 设置界面可以对录制相关参数进行自定义修改,主要可修改录制参数包括:设备信息、帧率、视频编码格式、cpu线程数、分辨率自适应或自定义等,以及自定义录制快捷键和输出视频文件夹。
16 |
17 | 6. **编译和打包。** 该项目是一个完整的安装包程序,安装界面定制显示客户公司相关的信息,客户在安装时可选择生成桌面快捷方式和开机启动等选项。
18 |
19 | #### 项目主要特色功能点:
20 | 1. **防盗版机制。** 通过注册表存储和验证安装信息防止复制运行实现简易防盗机制,限制非正常安装用户使用(客户将软件和自身硬件产品一起打包出售给他们的客户)。
21 |
22 | 2. **按日期归档录制产生的文件。** 文件名区分录制方式,标注录制时间,每天录制产生的视频文件在单独的文件夹内。
23 |
24 | 3. **多种录制设备可选择切换。** 应对缩放的屏幕可选择GDI(图形设备接口)录制方式。
25 |
26 | 4. **检测到录制非人为断开,自动重新启动录制。** 解决了某些录制设备在windows10系统中运行不兼容,录制时间长之后会随机断开的问题。
27 |
28 | #### 交付效果:
29 |
30 | 项目实际运行效果:在参数设置为分辨率=1024x768、帧率=30帧/s、视频编码=h264、threads=4的情况下,在i5计算机上进行录制,cpu占有率保持在30%~40%之间。保证录制清晰度的同时不会影响到计算机运行其他程序的资源。
31 |
32 | ## 2. 运行配置
33 | ### 1. 运行环境和所需组件
34 | 1. [Python3](https://www.python.org/downloads)
35 | 2. 安装依赖组件,-i是代理地址,使用代理下载速度会加快一点:
36 | ```python
37 | pip install -r requirements.txt -i https://pypi.douban.com/simple
38 | ```
39 | 3. 录制屏幕需要下载[Screen Capture Recorder](https://sourceforge.net/projects/screencapturer/)
40 | 4. 安装编译工具cx_Freeze(如果需要)。
41 | ```python
42 | pip install cx_freeze
43 | ```
44 | 5. 下载安装打包工具[Inno Setup](http://www.jrsoftware.org/isinfo.php)(如果需要打包)。
45 | ### 2. 在命令行下运行
46 | ```python
47 | python recordwindow.py
48 | #Win10-64系统稳定运行,其他系统暂未测试。
49 | ```
50 | ### 3. 设置
51 | 参考设置如下:
52 | * 摄像头名称:USB2.0 HD UVC WebCam
53 | * 声音输入设备:麦克风 (Realtek High Definition Audio)
54 | * 屏幕录制设备:screen-capture-recorder
55 | * 系统声音设备:virtual-audio-capturer
56 |
57 | 不同机器和设备名称有所不同。
58 | ### 4. 编译
59 | ```
60 | python csetup.py build
61 | #默认编译的可执行文件生成在目录:D:\dev\record\record-win
62 | #参照csetup.py修改编译信息
63 | ```
64 | ### 5. 打包
65 | 用Inno setup打开setup.iss文件,修改必要信息,然后编译执行。
66 | ### 6. 开发总结
67 | [请参见总结文章](https://segmentfault.com/a/1190000015409826)
68 |
--------------------------------------------------------------------------------
/RecordConfig.py:
--------------------------------------------------------------------------------
1 | import os,configparser
2 | # import DevicesInfo
3 | # from DevicesInfo import *
4 |
5 | class RecordConfig():
6 | def __init__(self, config_file_name = 'configByLinxiao.ini'):
7 | self.file_name = config_file_name
8 | self.encoding = 'gb2312'
9 | self.load()
10 |
11 | def load(self):
12 |
13 | if os.path.exists(self.file_name):
14 | self.config=configparser.SafeConfigParser()
15 | self.config.read(self.file_name, encoding = self.encoding)
16 | else:
17 | self.write_default_config()
18 | self.load()
19 |
20 | def write_default_config(self):
21 | print('初始化配置文件.')
22 | conf = configparser.SafeConfigParser()
23 |
24 | # di = DevicesInfo()
25 | devices_section_name = 'devices'
26 | conf.add_section(devices_section_name)
27 | conf.set(devices_section_name,'camera_device_name','')
28 | conf.set(devices_section_name,'voice_device_name','')
29 | conf.set(devices_section_name,'screen_device_name','')
30 | conf.set(devices_section_name,'system_voice_device_name','')
31 |
32 | shortcut_section_name = 'shortcut'
33 | conf.add_section(shortcut_section_name)
34 | conf.set(shortcut_section_name,'camera','160,162,164,65')
35 | conf.set(shortcut_section_name,'screen','160,162,164,66')
36 | conf.set(shortcut_section_name,'stop','160,162,164,67')
37 |
38 | record_section_name = 'record'
39 | conf.add_section(record_section_name)
40 | conf.set(record_section_name,'resolution','1920x1080')
41 | conf.set(record_section_name,'adaptive_screen_resolution','1')
42 | conf.set(record_section_name,'vcodec','libx264')
43 | conf.set(record_section_name,'frame_rate','7.0')
44 | conf.set(record_section_name,'file_dir','.')
45 | conf.set(record_section_name,'threads', '4')
46 |
47 | conf.add_section('author')
48 | conf.set('author', 'name', 'linxiao')
49 | conf.set('author', 'mail', '940950943@qqqqqqqqqqqqqqqqqqqqqqqqqqqq.com')
50 |
51 | self.config = conf
52 | self.write()
53 |
54 | def write(self):
55 | with open(self.file_name, 'wt', encoding = self.encoding) as configfp:
56 | self.config.write(configfp)
57 |
58 |
--------------------------------------------------------------------------------
/RecordHelp.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Form implementation generated from reading ui file 'help.ui'
4 | #
5 | # Created by: PyQt5 UI code generator 5.10
6 | #
7 | # WARNING! All changes made in this file will be lost!
8 |
9 | from PyQt5 import QtCore, QtGui, QtWidgets
10 | from PyQt5.QtWidgets import QWidget
11 | from PyQt5.QtCore import QResource
12 | import sys
13 | import resource
14 |
15 | class RecordHelp(QWidget):
16 |
17 | def __init__(self, parent = None):
18 | super(RecordHelp, self).__init__(parent)
19 | self.setupUi()
20 |
21 | def setupUi(self):
22 | self.setObjectName("Form")
23 | self.setFixedSize(600, 310)
24 | # QResource.registerResource('C:\Users\lv\ctest\record-camera-and-screen\test.qrc', 'resource')
25 | icon = QtGui.QIcon()
26 | icon.addPixmap(QtGui.QPixmap(":/resource/gutin.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
27 | self.setWindowIcon(icon)
28 | self.frame = QtWidgets.QFrame(self)
29 | self.frame.setGeometry(QtCore.QRect(60, 330, 229, 10))
30 | self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
31 | self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
32 | self.frame.setObjectName("frame")
33 | self.label = QtWidgets.QLabel(self)
34 | self.label.setGeometry(QtCore.QRect(40, 30, 181, 181))
35 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
36 | sizePolicy.setHorizontalStretch(0)
37 | sizePolicy.setVerticalStretch(0)
38 | sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
39 | self.label.setSizePolicy(sizePolicy)
40 | self.label.setText("")
41 | self.label.setPixmap(QtGui.QPixmap(":/resource/gutin.jpg"))
42 | self.label.setScaledContents(True)
43 | self.label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
44 | self.label.setObjectName("label")
45 | self.label_2 = QtWidgets.QLabel(self)
46 | self.label_2.setGeometry(QtCore.QRect(250, 30, 281, 31))
47 | self.label_2.setScaledContents(False)
48 | self.label_2.setObjectName("label_2")
49 | self.status_title = QtWidgets.QLabel(self)
50 | self.status_title.setGeometry(QtCore.QRect(250, 60, 331, 51))
51 | font = QtGui.QFont()
52 | font.setPointSize(10)
53 | font.setBold(False)
54 | font.setWeight(50)
55 | self.status_title.setFont(font)
56 | self.status_title.setScaledContents(True)
57 | self.status_title.setWordWrap(True)
58 | self.status_title.setObjectName("status_title")
59 | self.start = QtWidgets.QLabel(self)
60 | self.start.setGeometry(QtCore.QRect(290, 130, 61, 61))
61 | font = QtGui.QFont()
62 | font.setPointSize(11)
63 | self.start.setFont(font)
64 | self.start.setText("")
65 | self.start.setPixmap(QtGui.QPixmap(":/resource/start.png"))
66 | self.start.setScaledContents(True)
67 | self.start.setObjectName("start")
68 | self.camera = QtWidgets.QLabel(self)
69 | self.camera.setGeometry(QtCore.QRect(380, 130, 61, 61))
70 | font = QtGui.QFont()
71 | font.setPointSize(11)
72 | self.camera.setFont(font)
73 | self.camera.setText("")
74 | self.camera.setPixmap(QtGui.QPixmap(":/resource/camera_recording_colorful.png"))
75 | self.camera.setScaledContents(True)
76 | self.camera.setObjectName("camera")
77 | self.screen = QtWidgets.QLabel(self)
78 | self.screen.setGeometry(QtCore.QRect(470, 130, 61, 61))
79 | font = QtGui.QFont()
80 | font.setPointSize(11)
81 | self.screen.setFont(font)
82 | self.screen.setText("")
83 | self.screen.setPixmap(QtGui.QPixmap(":/resource/screen_recording.png"))
84 | self.screen.setScaledContents(True)
85 | self.screen.setObjectName("screen")
86 | self.start_label = QtWidgets.QLabel(self)
87 | self.start_label.setGeometry(QtCore.QRect(290, 200, 61, 16))
88 | self.start_label.setObjectName("start_label")
89 | self.camera_label = QtWidgets.QLabel(self)
90 | self.camera_label.setGeometry(QtCore.QRect(380, 200, 61, 16))
91 | self.camera_label.setObjectName("camera_label")
92 | self.start_label_2 = QtWidgets.QLabel(self)
93 | self.start_label_2.setGeometry(QtCore.QRect(480, 200, 51, 16))
94 | self.start_label_2.setObjectName("start_label_2")
95 | self.label_3 = QtWidgets.QLabel(self)
96 | self.label_3.setGeometry(QtCore.QRect(40, 240, 541, 41))
97 | font = QtGui.QFont()
98 | font.setFamily("Agency FB")
99 | font.setPointSize(10)
100 | self.label_3.setFont(font)
101 | self.label_3.setWordWrap(True)
102 | self.label_3.setObjectName("label_3")
103 | self.frame.raise_()
104 | self.label.raise_()
105 | self.label_2.raise_()
106 | self.status_title.raise_()
107 | self.start.raise_()
108 | self.camera.raise_()
109 | self.screen.raise_()
110 | self.start_label.raise_()
111 | self.camera_label.raise_()
112 | self.start_label_2.raise_()
113 | self.label_3.raise_()
114 |
115 | self.retranslateUi()
116 | QtCore.QMetaObject.connectSlotsByName(self)
117 |
118 | def retranslateUi(self):
119 | _translate = QtCore.QCoreApplication.translate
120 | self.setWindowTitle(_translate("Form", "帮助"))
121 | self.label_2.setText(_translate("Form", "
谷田会议视频录播管理系统-帮助
"))
122 | self.label_2.setStyleSheet('color:blue')
123 | self.status_title.setText(_translate("Form", "1.软件主要功能是录制摄像头和录制屏幕,有非录制状态、录制摄像头、录制屏幕三种状态主要以托盘图标的变化来区分:"))
124 | self.status_title.setStyleSheet('font-weight:bold')
125 | self.start_label.setText(_translate("Form", "非录制状态"))
126 | self.camera_label.setText(_translate("Form", "录制摄像头"))
127 | self.start_label_2.setText(_translate("Form", "录制屏幕"))
128 | self.label_3.setText(_translate("Form", "2.此软件需配合谷田智能会议硬件使用,已申请国家专利,未经事先书面许可,严禁进行任何形式的仿制、改装并用于销售、复制、改编或翻译,除非版权法另有规定。"))
129 | self.label_3.setStyleSheet('font-weight:bold')
130 |
131 |
132 | def showWindow(self):
133 | if not self.isVisible():
134 | self.show()
135 |
136 | def closeEvent(self, event):
137 | # self.setVisible(False)
138 | # event.ignore()
139 | pass
140 |
141 | if __name__ == '__main__':
142 | app = QtWidgets.QApplication(sys.argv)
143 | rh = RecordHelp()
144 | rh.show()
145 | sys.exit(app.exec_())
--------------------------------------------------------------------------------
/RecordTrayIcon.py:
--------------------------------------------------------------------------------
1 | import sys,os
2 | from PyQt5 import QtWidgets,QtGui
3 | from PyQt5.QtWidgets import *
4 | from PyQt5.QtCore import *
5 | from PyQt5.QtGui import *
6 | import RecordType
7 | from RecordType import *
8 | import resource
9 |
10 | class RecordTrayIcon(QSystemTrayIcon):
11 | def __init__(self, parent=None):
12 | super(RecordTrayIcon, self).__init__(parent)
13 | # print((p_menu.actions()))
14 | # self.showAction1 = QAction("显示消息1", self, triggered=self.showM)
15 | # print(type(self.parent))
16 | # p_menu.insertAction(p_menu.actions()[len(p_menu.actions())-1], self.showAction1)
17 |
18 | # self.showMenu()
19 | self.createContextMenu(parent)
20 | self.interactive()
21 | # self.update_state(False,None)
22 |
23 |
24 | def createContextMenu(self, parent):
25 | p_menu = parent.contextMenu
26 | self.setContextMenu(p_menu)
27 |
28 | def interactive(self):
29 | self.activated.connect(self.iconClicked)
30 | self.toolTip()
31 |
32 | def showMessage():
33 | pass
34 |
35 | def get_icon(self, file_name):
36 |
37 | data_dir=''
38 |
39 | if getattr(sys, 'frozen', False):
40 | # The application is frozen
41 | data_dir = os.path.dirname(sys.executable)
42 | else:
43 | # The application is not frozen
44 | # Change this bit to match where you store your data files:
45 | data_dir = os.path.dirname(__file__)
46 |
47 | resource_dir = 'resource'
48 | data_dir = os.path.join(os.path.abspath(data_dir), resource_dir)
49 | print('resource dir: %s' % data_dir)
50 |
51 | icon_file_path = os.path.join(data_dir, file_name)
52 | if os.path.isfile(icon_file_path):
53 | return QIcon(icon_file_path)
54 | return None
55 |
56 | def update_state(self, recording, record_type):
57 |
58 | if recording:
59 | if record_type == RecordType.Camera:
60 | # self.setIcon(self.get_icon('camera_recording_colorful.png'))
61 | self.setIcon(QIcon(':/resource/camera_recording_colorful.png'))
62 | self.setToolTip('正在录制摄像头...')
63 |
64 | elif record_type == RecordType.Screen:
65 | # self.setIcon(self.get_icon('screen_recording.png'))
66 | self.setIcon(QIcon(':/resource/screen_recording.png'))
67 | self.setToolTip('正在录制屏幕...')
68 | else:
69 | # self.setIcon(self.get_icon('stop.png'))
70 | # self.setIcon(QIcon(':/resource/stop.png'))
71 | self.setToolTip('软件缩小在这里.')
72 | else:
73 | # self.setIcon(self.get_icon('start.png'))
74 | self.setIcon(QIcon(':/resource/start.png'))
75 | self.setToolTip('软件缩小在这里.')
76 |
77 |
78 | def iconClicked(self, reason):
79 | #"鼠标点击icon传递的信号会带有一个整形的值,1是表示单击右键,2是双击,3是单击左键,4是用鼠标中键点击"
80 | if reason == 2 or reason == 3:
81 | print('clicked.')
82 | pw = self.parent()
83 | # print('trayicon is activateWindow?:%s' % self.isActiveWindow())
84 | if pw.isVisible(): #and pw.isActiveWindow()
85 | # print('pw is active?%s' % pw.isActiveWindow())
86 | if not pw.isActiveWindow():
87 | pw.activateWindow()
88 | # pw.raise_()
89 | else:
90 | pw.hide()
91 | # pw.hide()
92 | pass
93 | else:
94 | pw.show()
95 | # pw.raise_()
96 | pw.activateWindow()
97 | # print('parent is active window? %s' % pw.isActiveWindow())
98 | # print(reason)
--------------------------------------------------------------------------------
/RecordType.py:
--------------------------------------------------------------------------------
1 | from enum import Enum
2 |
3 | class RecordType(Enum):
4 | #摄像头
5 | Camera = 0
6 | #屏幕
7 | Screen = 1
--------------------------------------------------------------------------------
/RecordVideo.py:
--------------------------------------------------------------------------------
1 | import datetime,time,sys,os,signal,re,winreg
2 | from datetime import datetime
3 | import subprocess,threading
4 | from subprocess import CalledProcessError
5 | # from multiprocessing import Process
6 | from threading import Thread
7 | import ctypes,inspect
8 | import RecordType
9 | from RecordType import *
10 | import RecordConfig
11 | from RecordConfig import *
12 | import logging
13 | import RunCMD
14 | from RunCMD import get_ffmpeg_path
15 | from winreg import HKEY_CURRENT_USER, OpenKey, QueryInfoKey, EnumValue, SetValueEx, CloseKey, REG_SZ, KEY_READ, KEY_SET_VALUE
16 |
17 | class RecordVideo():
18 |
19 |
20 | '''
21 | ffmpeg -f dshow -i video="@device_pnp_\\\\?\\usb#vid_04f2&pid_b354&mi_00#7&30d7ad30&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global":audio="@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{571529B3-7DB3-42A3-ADEF-BBD82925C15D}" -acodec libmp3lame -vcodec libx265 -preset:v ultrafast -tune:v zerolatency -s 1920x1080 -r 7 -y record_camera_20180408_182541.mkv
22 |
23 | '''
24 |
25 | def __init__(self, record_video=True, record_voice=True):
26 | # print('视频录制初始化中...')
27 | # self.record_video=record_video
28 | # self.record_voice=record_voice
29 | #录制状态
30 | self.recording = False
31 | self.exception_exit = False
32 | self.record_type=RecordType.Camera
33 | #文件名称
34 | self.file_name='record'
35 | #文件后缀
36 | self.file_suffix='.mkv'
37 | self.process = None
38 | self.record_thread_name='record'
39 | self.record_thread=None
40 |
41 | self.file_dir = ''
42 | self.load()
43 |
44 | def load(self):
45 | #日志
46 | self.logger = logging.getLogger(__name__)
47 | self.logger.setLevel(level = logging.INFO)
48 | handler = logging.FileHandler('log.txt')
49 | handler.setLevel(logging.INFO)
50 | formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
51 | handler.setFormatter(formatter)
52 |
53 | self.logger.addHandler(handler)
54 |
55 | self.load_config()
56 |
57 |
58 | def load_config(self):
59 |
60 | rc = RecordConfig()
61 | self.config = rc.config
62 |
63 | #摄像头名称
64 | self.camera_name=rc.config.get('devices','camera_device_name')
65 | #麦克风名称
66 | self.voice_device_name=rc.config.get('devices','voice_device_name')
67 | #录制屏幕名称
68 | self.screen_name=rc.config.get('devices','screen_device_name')
69 | #系统声音设备名称
70 | self.system_voice_device_name=rc.config.get('devices','system_voice_device_name')
71 | #视频编码
72 | self.video_codec=rc.config.get('record','vcodec')
73 | #分辨率
74 | self.resolution=rc.config.get('record','resolution')
75 | #是否自适应屏幕录制分辨率
76 | self.adaptive_screen_resolution = rc.config.getboolean('record', 'adaptive_screen_resolution')
77 | #帧率
78 | self.brate=rc.config.getfloat('record','frame_rate')
79 | #文件目录
80 | self.file_dir= os.path.abspath(rc.config.get('record','file_dir'))
81 | #线程数
82 | self.threads = rc.config.getint('record','threads')
83 |
84 | self.logger.info('camera device name: %s' % self.camera_name)
85 | self.logger.info('voice device name: %s' % self.voice_device_name)
86 | self.logger.info('screen device name: %s' % self.screen_name)
87 | self.logger.info('system voice device name: %s' % self.system_voice_device_name)
88 | self.logger.info('vcodec: %s' % self.video_codec)
89 | self.logger.info('resolution: %s' % self.resolution)
90 | self.logger.info('frame rate: %s' % self.brate)
91 | self.logger.info('save dir: %s' % self.file_dir)
92 |
93 |
94 | def start_ffmpeg(self,cmd, shell = True):
95 |
96 | try:
97 | print('录制中...')
98 | self.logger.info('录制中...')
99 | # print('cmd:\n%s' % cmd)
100 | start_time = datetime.now()
101 | self.process=subprocess.Popen(cmd, shell=shell, universal_newlines = True, stdin = subprocess.PIPE, stderr = subprocess.STDOUT, stdout = subprocess.PIPE)
102 | line = ''
103 | while self.recording:
104 |
105 | # print(cmd)
106 | # print(self.recording)
107 | # tmp_out = self.process.stdout.readline()
108 | line += str(self.process.stdout.readline())
109 | # print('test tmp out:%s' % tmp_out)
110 | #文字输出编码错误记录
111 | #异常:UnicodeDecodeError: 'gbk' codec can't decode byte 0xb4 in position 2881: illegal multibyte sequence
112 | #原因:cmd输出包含中文字符
113 | #解决方案:universal_newlines = False
114 | #缺陷:需要以字节形式的q来控制退出:write(b'q')
115 | #最终原因及解决方案:引起gbk编码错误的原因是文件名的中文与数字的连接符号由下划线'_'改成了横杠'-'。
116 | #为什么这个修改会引起运行时ffmpeg报编码错误,推测终究还是ffmpeg对中文编码的支持问题。
117 | #最终方案即文件名中的中文后的连接符号改回下划线。
118 |
119 | now = datetime.now()
120 | if (now - start_time).total_seconds() >2:
121 | # self.logger.info('recording...')
122 | ffmpeg_running = False
123 | if self.process:
124 | ffmpeg_running = self.process.poll() is None
125 | log_text = 'ffmpeg 运行状态:%s' % ('运行中' if ffmpeg_running else '终止')
126 |
127 | print(log_text)
128 | self.logger.info(log_text)
129 |
130 | else:
131 | txt= 'ffmpeg子进程已终止.'
132 | print(txt)
133 | self.logger.warning(txt)
134 |
135 | if not ffmpeg_running:
136 |
137 | print(self.process.communicate())
138 | raise CalledProcessError(self.process.returncode, cmd)
139 |
140 | # self.logger.info(line)
141 | print(line)
142 | line = ''
143 | start_time = now
144 |
145 | # print(line)
146 |
147 | if not self.recording:
148 | self.process.stdin.write('q')
149 | print(self.process.communicate())
150 | break
151 |
152 | except CalledProcessError as e:
153 | log_txt = 'ffmpeg异常终止:\nreturn code: %d\ncmd:\n%s' % (e.returncode, e.cmd)
154 | print(log_txt)
155 | self.logger.warning(log_txt)
156 | self.recording = False
157 | self.exception_exit = True
158 | print('process is None?:%s' % (self.process is None))
159 | # self.stop_record()
160 | except Exception as x:
161 | print('未捕获的异常:')
162 | print(x)
163 | # self.logger.info(self.process.communicate())
164 | # print('over')
165 |
166 | def record(self, cmd='ffmpeg -h', target = None):
167 |
168 | if target:
169 | cmd = os.path.join(get_ffmpeg_path(), cmd)
170 | print('cmd: \n%s' % cmd)
171 | self.logger.info('record cmd:\n %s' % cmd)
172 | self.record_thread = Thread(name=self.record_thread_name, target= target, args = (cmd,), daemon=True)
173 | self.record_thread.start()
174 | self.recording=True
175 | self.exception_exit = False
176 |
177 | print('record thread,ident:%d' % self.record_thread.ident)
178 | # th.join()
179 |
180 | def stop_record(self):
181 |
182 | # print('threading active thread count:%d' % threading.active_count())
183 | try:
184 |
185 | self.recording = False
186 | self.logger.info('录制将停止...')
187 | if self.process:
188 | self.logger.info('ffmpeg进程状态: %s' % (self.process.poll() is not None))
189 | if self.process.returncode:
190 | print('subprocess return code:%d' % self.process.returncode)
191 | print('record thread status: %s' % self.record_thread.is_alive())
192 |
193 | if self.record_thread.is_alive():
194 |
195 | self.record_thread.join(1)
196 | print('record thread status: %s' % self.record_thread.is_alive())
197 | except (Exception,KeyboardInterrupt) as e:
198 | print('kill exception:\n %s' % e)
199 | self.logger.warning('kill exception:\n %s' % e)
200 |
201 | def record_camera(self):
202 |
203 | if self.camera_name and self.voice_device_name:
204 |
205 | self.record_type=RecordType.Camera
206 | record_cmd='ffmpeg -f dshow -i video=\"%s\":audio=\"%s\" -acodec libmp3lame -vcodec %s -preset:v ultrafast -tune:v zerolatency -s %s -r %d -threads %d -y %s' %(
207 | self.deal_with_device_name(self.camera_name),
208 | self.deal_with_device_name(self.voice_device_name),
209 | self.video_codec,
210 | self.resolution,
211 | self.brate,
212 | self.threads,
213 | self.get_file_name()
214 | )
215 | # print(record_cmd)
216 | self.record(record_cmd, self.start_ffmpeg)
217 |
218 | def get_screen_device(self):
219 | pass
220 |
221 | def record_screen(self, resolution='1024x768'):
222 | if self.screen_name and self.system_voice_device_name:
223 | self.record_type=RecordType.Screen
224 | if self.adaptive_screen_resolution is not True:
225 | resolution = self.resolution
226 | device_cmd_str = ''
227 | if self.screen_name.lower().find('gdigrab') >=0:
228 | #使用gdigrab录制屏幕
229 | device_cmd_str = '-f dshow -i audio="{}" -f gdigrab -i desktop'.format(self.system_voice_device_name)
230 | else:
231 | device_cmd_str = '-f dshow -i video="{}":audio="{}"'.format(self.screen_name, self.system_voice_device_name)
232 | record_cmd='ffmpeg {} -acodec libmp3lame -vcodec {} -preset:v ultrafast -tune:v zerolatency -s {} -r {} -threads {} -y {}'.format(
233 | device_cmd_str,
234 | self.video_codec,
235 | # '1024x768', #屏幕录制分辨率固定
236 | resolution,
237 | self.brate,
238 | self.threads,
239 | self.get_file_name()
240 | )
241 | self.record(record_cmd, self.start_ffmpeg)
242 |
243 | def check_device(self):
244 | #简单验证摄像头设置是否为空
245 | ready = True
246 | l_msg = ''
247 | if not self.camera_name:
248 | ready = False
249 | l_msg += '摄像头设备为空\n'
250 |
251 | if not self.voice_device_name:
252 | ready = False
253 | l_msg += '麦克风设备为空\n'
254 |
255 | if not self.screen_name:
256 | ready = False
257 | l_msg += '屏幕录制驱动为空\n'
258 |
259 | if not self.system_voice_device_name:
260 | ready = False
261 | l_msg += '系统声音录制驱动为空\n'
262 |
263 | if ready:
264 | l_msg = '设备检测正常'
265 | print(l_msg)
266 | self.logger.info(l_msg)
267 | return ready
268 |
269 |
270 | def check_run_state(self):
271 | #验证运行有效性逻辑:
272 | #一、判断是否正常安装
273 | #判断条件:软件安装时在注册表“HKEY_CURRENT_USER\\SOFTWARE\\Gutin\\Record“记录下安装目录
274 | #二、非正常安装有效时间为三个月,且只能发生一次
275 |
276 | #验证当前运行目录是否存在注册表中
277 | qualified = False
278 | run_dir = os.path.abspath('.')
279 | # print('run_dir:%s' % run_dir)
280 | reg_path = 'SOFTWARE\\Gutin\\Record'
281 | feature_name ='InstallDir'
282 | key = OpenKey(HKEY_CURRENT_USER, reg_path, access = KEY_READ)
283 | items = QueryInfoKey(key)
284 | for i in range(items[1]):
285 | item = EnumValue(key, i)
286 | name = item[0]
287 | value = item[1]
288 | type = item[2]
289 | if name and name.find(feature_name)>=0:
290 | if os.path.samefile(value, run_dir):
291 | qualified = True
292 | break;
293 |
294 | if not qualified:
295 | #查找非正常安装目录记录
296 | #记录以运行目录的hash值作为键名,值为首次运行的时间
297 | time_format= '%Y-%m-%d %H:%M:%S'
298 | run_time = None
299 | unqualified_key_name = 'Unqualified'
300 | has_unqualified = False
301 | for i in range(items[1]):
302 | item = EnumValue(key, i)
303 | name = item[0]
304 | value = item[1]
305 | type = item[2]
306 | if name == unqualified_key_name:
307 | has_unqualified = True
308 | run_time = value
309 |
310 | if not has_unqualified:
311 | #如果不存在,创建
312 | run_time = datetime.now().strftime(time_format)
313 | key = OpenKey(HKEY_CURRENT_USER, reg_path, access = KEY_SET_VALUE)
314 | SetValueEx(key, unqualified_key_name, 0, REG_SZ, run_time)
315 |
316 | #判断时限
317 | # now = datetime.strptime('2018-06-22 12:11:51', time_format)
318 | now = datetime.now()
319 | run_time_obj = datetime.strptime(run_time, time_format)
320 | print('first run_time:%s' % run_time)
321 | print('now:%s' % now.strftime(time_format))
322 |
323 | qual_days = 91 - (now - run_time_obj).days
324 | # print('qualified days:%d' % (qual_days))
325 | # qual_hours = (now - run_time_obj).total_seconds() // 3600
326 | if qual_days > 0:
327 | # if 5 - qual_hours > 0:
328 | qualified = True
329 |
330 | CloseKey(key)
331 | return qualified
332 |
333 |
334 | def debug_camera(self):
335 | try:
336 | play_cmd = ['ffplay','-f','dshow','-i','video={}'.format(self.camera_name),'-window_title','按q退出','-noborder']
337 | self.record(play_cmd, self.play)
338 | except Exception as e:
339 | print(e)
340 |
341 | def play(self, cmd):
342 | try:
343 | t_process=subprocess.Popen(cmd, shell= False, universal_newlines = True, stderr = subprocess.STDOUT, stdout = subprocess.PIPE)
344 | while True:
345 | line = t_process.stdout.readline()
346 | print(line)
347 | if line == '':
348 | if t_process.poll() is not None:
349 | break
350 | t_process.communicate()
351 | except (Exception, KeyboardInterrupt) as e:
352 | print(e)
353 |
354 | def deal_with_device_name(self,device_name):
355 | # print(device_name)
356 | # new_name=device_name.replace('\\','\\\\')
357 | # print(new_name)
358 | # return new_name
359 | return device_name
360 |
361 | def get_file_name(self):
362 | date_dir = datetime.now().strftime('%Y-%m-%d')
363 | time_str = datetime.now().strftime('%Y-%m-%d-%H%M%S')
364 | video_type_name = ''
365 | if self.record_type == RecordType.Camera:
366 | # video_type_name = 'camera'
367 | video_type_name = '摄像头'
368 | if self.record_type == RecordType.Screen:
369 | video_type_name = '屏幕'
370 | # video_type_name = 'screen'
371 |
372 | today_file_dir = os.path.join(self.file_dir, date_dir)
373 | if not os.path.exists(today_file_dir):
374 | os.mkdir(today_file_dir)
375 | file_name = os.path.join(today_file_dir, '{}_{}{}'.format(video_type_name, time_str, self.file_suffix))
376 | print('recording file name: %s' % file_name)
377 | return file_name
378 |
379 | def _async_raise(self, tid, exctype):
380 | """raises the exception, performs cleanup if needed"""
381 | tid = ctypes.c_long(tid)
382 | if not inspect.isclass(exctype):
383 | exctype = type(exctype)
384 | res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
385 | print('async_raise res value:%d' % res)
386 | if res == 0:
387 | raise ValueError("invalid thread id")
388 | elif res != 1:
389 | # """if it returns a number greater than one, you're in trouble,
390 | # and you should call it again with exc=NULL to revert the effect"""
391 | ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
392 | raise SystemError("PyThreadState_SetAsyncExc failed")
393 |
394 | def kill_process(self, process_name='ffmpeg'):
395 | cmd='tasklist | findstr {}'.format(process_name)
396 | output_strs, output_errs=self.run_cmd(cmd)
397 | pid=[]
398 | if output_strs:
399 | print('find "%s" result: \n%s' % (process_name, ''.join(output_strs)))
400 | for output_str in output_strs:
401 | find_re=re.search(r'({}.+?)\s*([0-9]+)'.format(process_name),output_str)
402 | if find_re:
403 | full_process_name=find_re.group(1).strip()
404 | pid=find_re.group(2).strip()
405 | print('计划结束任务:{}@pid: {}'.format( full_process_name, pid ))
406 | task_kill_cmd = 'taskkill /T /F /pid {}'.format(pid)
407 | # status, output = subprocess.getstatusoutput(task_kill_cmd)
408 |
409 | # if status == 1:
410 | # print('任务成功被结束:')
411 | # else:
412 | # print('任务结束失败:')
413 | # print(output)
414 |
415 | else:
416 | print('not found task about "%s" in tasklist' % process_name )
417 |
418 |
419 | # def stop_thread(self,thread):
420 | # self._async_raise(thread.ident, SystemExit)
421 |
422 |
--------------------------------------------------------------------------------
/RecordWindow.py:
--------------------------------------------------------------------------------
1 | import sys, datetime
2 | import PyQt5
3 | from PyQt5 import QtCore, QtGui, QtWidgets
4 | from PyQt5.QtCore import Qt, QCoreApplication
5 | from PyQt5.QtWidgets import QMessageBox
6 | import RecordVideo,RecordType
7 | from RecordVideo import *
8 | from RecordType import *
9 | import SettingWindow
10 | from SettingWindow import *
11 | import Shortcut
12 | from Shortcut import *
13 | import RecordTrayIcon
14 | from RecordTrayIcon import *
15 | import RecordConfig
16 | from RecordConfig import *
17 | import RecordHelp
18 | from RecordHelp import *
19 |
20 | class RecordWindow(QtWidgets.QWidget):
21 |
22 | def __init__(self, parent = None, screen_resolution=None):
23 | super(RecordWindow,self).__init__(parent)
24 | self.setupUi()
25 | self.load_modules()
26 | #更新设置
27 | self.need_update_config = False
28 | self.screen_resolution = screen_resolution
29 | # self.need_hide = True
30 | #初始化状态
31 | print('初始化状态...')
32 | self.update_state()
33 |
34 | def load_modules(self):
35 | #录制
36 | self.rv=RecordVideo()
37 | #鼠标拖动
38 | self.m_drag = False
39 | #托盘图标
40 | self.rti = RecordTrayIcon(self)
41 | self.rti.update_state(self.recording, self.record_type)
42 |
43 | self.sc = Shortcut()
44 |
45 | self.update_setting(True)
46 | # self.rc = RecordConfig()
47 | # self.file_dir = self.rc.config.get('record','file_dir')
48 | # self.debugCameraAction.triggered.connect(self.rv.debug_camera)
49 |
50 | def closeEvent(self, event):
51 | # print('close window.')
52 | # self.close_signal.emit()
53 | # self.close()
54 | if self.recording:
55 |
56 | self.stop_record(force = True)
57 | # question = QMessageBox(self)
58 | # question.setText('系统正在录制中,确定要退出吗?')
59 | # question.setWindowTitle('提示')
60 | # question.setIcon(QMessageBox.Question)
61 | # question.addButton(QMessageBox.Yes)
62 | # question.addButton(QMessageBox.No)
63 | # question.setDefaultButton(QMessageBox.No)
64 | # ret = question.exec()
65 | # if ret == QMessageBox.Yes:
66 | # self.stop_record()
67 | # QCoreApplication.instance().quit()
68 |
69 | # else:
70 |
71 | # question = QMessageBox()
72 | # question.setText('确定要退出吗?')
73 | # question.setWindowTitle('提示')
74 | # question.setIcon(QMessageBox.Question)
75 | # question.addButton(QMessageBox.Yes)
76 | # question.addButton(QMessageBox.No)
77 | # question.setDefaultButton(QMessageBox.No)
78 | # ret = question.exec()
79 | # if ret == QMessageBox.Yes:
80 |
81 | print('软件将退出.')
82 | QCoreApplication.instance().quit()
83 |
84 | # event.ignore()
85 |
86 |
87 |
88 | def setupUi(self):
89 | self.setObjectName("RecordWindow")
90 | self.resize(94, 81)
91 | self.move(1100,600)
92 | self.pushButton = QtWidgets.QPushButton(self)
93 | self.pushButton.setGeometry(QtCore.QRect(0, 30, 91, 51))
94 | self.pushButton.setObjectName("pushButton")
95 | # self.register_slot(self.pushButton.clicked, self.record)
96 | # self.pushButton.mousePressEvent.connect(self.mousePressEvent)
97 | # print(dir(self.pushButton))
98 |
99 | #添加右键菜单
100 | self.createContextMenu()
101 |
102 | #添加计时器
103 | self.lcd = QLCDNumber(self)
104 | self.lcd.setDigitCount(10)
105 | self.lcd.setMode(QLCDNumber.Dec)
106 | self.lcd.setGeometry(QtCore.QRect(0, 0, 91, 31))
107 | self.lcd.setSegmentStyle(QLCDNumber.Flat)
108 | self.init_lcd()
109 |
110 | #新建一个QTimer对象
111 | self.timer = QTimer()
112 | self.timer.setInterval(1000)
113 | self.timer.timeout.connect(self.onTimerOut)
114 |
115 | self.retranslateUi()
116 |
117 | #调整窗体属性
118 | self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool)
119 | # self.setFocusPolicy(QtCore.Qt.StrongFocus)
120 | self.installEventFilter(self)
121 |
122 |
123 | def retranslateUi(self):
124 | _translate = QtCore.QCoreApplication.translate
125 | self.setWindowTitle(_translate("RecordWindow", "RecordWindow"))
126 | self.pushButton.setText(_translate("RecordWindow", "开始"))
127 |
128 |
129 | def init_lcd(self):
130 | self.lcd.display('0:00:00')
131 |
132 | def start_timer(self):
133 | self.start_time = datetime.now()
134 | self.init_lcd()
135 | self.timer.start()
136 |
137 | def stop_timer(self):
138 | self.timer.stop()
139 | self.init_lcd()
140 |
141 | # 刷新录制时间
142 | def onTimerOut(self):
143 | print('on timer out monitor record status :%s' % self.recording)
144 | if self.recording:
145 | self.lcd.display(self.get_display_time(self.start_time))
146 | else:
147 | # self.stop_timer()
148 | self.stop_record(force = self.exception_exit)
149 |
150 | if self.exception_exit:
151 | time.sleep(2)
152 | self.record(self.record_type)
153 |
154 | def get_display_time(self,old_time):
155 | delta_time = datetime.now() - old_time
156 | delta_time_str = str(delta_time)
157 | pos = delta_time_str.find('.')
158 | time_text = delta_time_str[0:pos]
159 | return time_text
160 |
161 | #打开文件目录
162 | def open_file_dir(self):
163 | dirpath = self.file_dir
164 | if os.path.isdir(dirpath):
165 | os.startfile(dirpath)
166 | else:
167 | print('错误的文件目录:%s' % dirpath)
168 |
169 | #显示菜单
170 | def showContextMenu(self):
171 | self.contextMenu.exec_(QtGui.QCursor.pos())
172 |
173 | #添加右键菜单
174 | def createContextMenu(self):
175 | #更改右键菜单为自定义
176 | print('初始化右键菜单...')
177 | self.setContextMenuPolicy(Qt.CustomContextMenu)
178 | self.customContextMenuRequested.connect(self.showContextMenu)
179 |
180 | self.contextMenu = QtWidgets.QMenu(self)
181 | #停止/开始录制
182 | self.recordSwitchAction = self.contextMenu.addAction('开始/停止录制')
183 | #开始录制摄像头
184 | self.recordCameraAction = self.contextMenu.addAction('开始录制摄像头')
185 | #录制屏幕
186 | self.recordScreenAction = self.contextMenu.addAction('开始录制屏幕')
187 | #分隔栏
188 | self.separatorAction = self.contextMenu.addAction('分隔栏')
189 | self.separatorAction.setSeparator(True)
190 | self.openFileDirAction = self.contextMenu.addAction('打开文件目录')
191 | self.openFileDirAction.triggered.connect(self.open_file_dir)
192 | #调试摄像头
193 | # self.debugCameraAction = self.contextMenu.addAction('调试摄像头')
194 | # self.debugCameraAction.setVisible(False)
195 | #设置
196 | self.settingAction=self.contextMenu.addAction('设置')
197 | self.sw = SettingWindow()
198 | self.settingAction.triggered.connect(self.show_setting)
199 | #帮助
200 | self.aboutAction=self.contextMenu.addAction('帮助')
201 | self.rh = RecordHelp()
202 | self.aboutAction.triggered.connect(self.rh.showWindow)
203 | #退出
204 | self.exitAction = self.contextMenu.addAction('退出')
205 | self.exitAction.triggered.connect(self.close)
206 |
207 |
208 | '''
209 | 功能事件
210 |
211 |
212 | '''
213 |
214 | @property
215 | def recording(self):
216 | return self.rv.recording
217 | @property
218 | def exception_exit(self):
219 | return self.rv.exception_exit
220 | @property
221 | def record_type(self):
222 | return self.rv.record_type
223 |
224 | def register_slot(self, event_obj, new_action, disconnect = True):
225 | if disconnect:
226 | try:
227 | event_obj.disconnect()
228 | except Exception as e:
229 | pass
230 | event_obj.connect(new_action)
231 |
232 | def update_state(self):
233 |
234 | if self.recording:
235 | print('录制状态:录制中.')
236 |
237 | if self.record_type == RecordType.Camera:
238 | print('正在录制摄像头.')
239 | else:
240 | print('正在录制屏幕.')
241 | print('recording:%s' % self.recording)
242 | print('record_type:%s' % self.record_type)
243 |
244 | if self.recording:
245 | self.recordSwitchAction.setText('停止录制')
246 | self.register_slot(self.pushButton.clicked, self.stop_record)
247 | self.register_slot(self.recordSwitchAction.triggered, self.stop_record)
248 |
249 | #正在录制摄像头
250 | if self.record_type == RecordType.Camera:
251 | self.pushButton.setText('正在录制摄像头\n点击停止')
252 | self.recordCameraAction.setText('停止录制摄像头')
253 | self.register_slot(self.recordCameraAction.triggered, self.stop_record)
254 |
255 | self.recordScreenAction.setText('开始录制屏幕')
256 | self.register_slot(self.recordScreenAction.triggered, lambda: self.record(RecordType.Screen))
257 | #正在录制屏幕
258 | if self.record_type == RecordType.Screen:
259 |
260 | self.pushButton.setText('正在录制屏幕\n点击停止')
261 | self.recordScreenAction.setText('停止录制屏幕')
262 | self.register_slot(self.recordScreenAction.triggered, self.stop_record)
263 |
264 | self.recordCameraAction.setText('开始录制摄像头')
265 | self.register_slot(self.recordCameraAction.triggered, lambda: self.record(RecordType.Camera))
266 |
267 | else:
268 | self.pushButton.setText('开始')
269 | self.recordSwitchAction.setText('开始录制')
270 | self.register_slot(self.pushButton.clicked, lambda: self.record(self.record_type))
271 | self.register_slot(self.recordSwitchAction.triggered, lambda: self.record(self.record_type))
272 |
273 | self.recordScreenAction.setText('开始录制屏幕')
274 | self.register_slot(self.recordScreenAction.triggered, lambda: self.record(RecordType.Screen))
275 |
276 | self.recordCameraAction.setText('开始录制摄像头')
277 | self.register_slot(self.recordCameraAction.triggered, lambda: self.record(RecordType.Camera))
278 |
279 | self.rti.update_state(self.recording, self.record_type)
280 |
281 | def stop_record(self, force = False):
282 | #force应用在两种情况:
283 | #1.timer实时刷新ffmpeg进程状态,当出现异常退时force=true,即force=exception_exit。
284 | #2.应用退出时
285 |
286 | if self.recording or force:
287 | self.stop_timer()
288 |
289 | if self.record_type == RecordType.Camera:
290 | print('停止录制摄像头.')
291 |
292 | if self.record_type == RecordType.Screen:
293 | print('停止录制屏幕.')
294 |
295 | try:
296 | self.rv.stop_record()
297 | except KeyboardInterrupt as e:
298 | print(e)
299 | finally:
300 | self.update_state()
301 | # else:
302 | # exit_tip = '系统即将退出'
303 | # print(exit_tip)
304 | # 退出系统
305 | # self.close()
306 |
307 | def record(self, rtype):
308 |
309 | if self.recording:
310 | if rtype == self.record_type:
311 | return True
312 |
313 | print('检测到正在录制,录制类型将切换...')
314 | self.stop_record()
315 |
316 | if self.rv.check_device():
317 | #开始录制
318 | if rtype == RecordType.Camera:
319 | print('开始录制摄像头...')
320 | self.rv.record_camera()
321 | elif rtype == RecordType.Screen:
322 | print('开始录制屏幕...')
323 | self.rv.record_screen(resolution=self.screen_resolution)
324 |
325 | self.start_timer()
326 | self.update_state()
327 | else:
328 | # self.need_hide = False
329 | # question = QMessageBox.information(self, '提示', '检测到录制设备缺失,无法进行录制,请先完善设备设置。', QMessageBox.Yes)
330 | # self.need_hide = True
331 | question = QMessageBox()
332 | question.setText('检测到录制设备缺失,无法进行录制,请先完善设备设置。')
333 | question.setWindowTitle('提示')
334 | question.setIcon(QMessageBox.Question)
335 | question.addButton(QMessageBox.Yes)
336 | tmp_btn = question.button(QMessageBox.Yes)
337 | tmp_btn.setText('确定')
338 |
339 | question.adjustSize()
340 | screen_center = QApplication.desktop().screenGeometry()
341 | question.move(((screen_center.width() - question.width()) /2), ((screen_center.height() - question.height())/2))
342 |
343 | # question.addButton(QMessageBox.No)
344 | # question.setDefaultButton(QMessageBox.No)
345 | ret = question.exec()
346 | # if ret == QMessageBox.Yes:
347 | # print('软件将退出.')
348 |
349 | def show_setting(self):
350 | # QWidget.connect(self.sw, update_setting(bool), self, self.update_setting(bool))
351 | self.sw.update_setting.connect(self.update_setting)
352 | self.sw.showSettingWindow()
353 |
354 | def update_setting(self, changed):
355 | if changed:
356 | print('update setting..')
357 | self.rv.load_config()
358 |
359 | self.rc = RecordConfig()
360 | self.load_shortcut()
361 |
362 | self.file_dir = self.rc.config.get('record','file_dir')
363 |
364 | ''''
365 | 鼠标拖动窗体
366 |
367 | '''
368 |
369 | def mousePressEvent(self, e):
370 | if not isinstance(self,RecordWindow):
371 | e.ignore()
372 | else:
373 | if e.button() == Qt.LeftButton:
374 | self.m_drag = True
375 | self.m_DragPosition = e.globalPos() - self.pos()
376 | e.accept()
377 | self.setCursor(QtGui.QCursor(Qt.OpenHandCursor))
378 |
379 | def mouseReleaseEvent(self, e):
380 | if not isinstance(self,RecordWindow):
381 | e.ignore()
382 | else:
383 | if e.button() == Qt.LeftButton:
384 | self.m_drag = False
385 | self.setCursor(QtGui.QCursor(Qt.ArrowCursor))
386 |
387 | def mouseMoveEvent(self, e):
388 | if not isinstance(self,RecordWindow):
389 | e.ignore()
390 | else:
391 | if Qt.LeftButton and self.m_drag:
392 | self.move(e.globalPos() - self.m_DragPosition)
393 | e.accept()
394 |
395 | # print('(x:%d/y:%d)' % (self.x(),self.y()))
396 |
397 | '''
398 | 快捷键监听
399 |
400 | '''
401 |
402 | def load_shortcut(self):
403 |
404 | self.sc.clear()
405 |
406 | camera_key_group = self.rc.config.get('shortcut','camera')
407 | screen_key_group = self.rc.config.get('shortcut','screen')
408 | stop_record_key_group = self.rc.config.get('shortcut','stop')
409 |
410 | camera_shortcut = [int(key) for key in camera_key_group.split(',')]
411 | screen_shortcut = [int(key) for key in screen_key_group.split(',')]
412 | stop_shortcut = [int(key) for key in stop_record_key_group.split(',')]
413 |
414 | print('camera shortcut: %s' % camera_shortcut)
415 | print('screen shortcut: %s' % screen_shortcut)
416 | print('stop shortcut: %s' % stop_shortcut)
417 |
418 | if camera_key_group:
419 | self.sc.add(1, camera_shortcut, lambda: self.record(RecordType.Camera))
420 | if screen_key_group:
421 | self.sc.add(2, screen_shortcut, lambda: self.record(RecordType.Screen))
422 | if stop_record_key_group:
423 | self.sc.add(3, stop_shortcut, self.stop_record)
424 |
425 |
426 | def monitor_shortcut(self):
427 |
428 | if self.rv.check_run_state():
429 |
430 | self.load_shortcut()
431 |
432 | self.sc.monitor()
433 |
434 | else:
435 | question = QMessageBox(self)
436 | question.setText('检测到软件非正常运行,以下功能将被禁用(如有疑问,请联系开发商):
')
437 | question.setWindowTitle('限制使用模式')
438 | question.setIcon(QMessageBox.Warning)
439 | question.addButton(QMessageBox.Yes)
440 | # question.setButtonText(QMessageBox.Yes, QString('确定'))
441 | btn = question.button(QMessageBox.Yes)
442 | # print(btn.text())
443 | btn.setText('确定')
444 | # question.addButton('确定', QMessageBox.ButtonRole.AcceptRole)
445 |
446 | # print('screen x:%d,y:%d; question x:%d,y:%d.' % (screen_center.x(), screen_center.y(), question.x(), question.y()))
447 | # print(question.frameGeometry())
448 | question.adjustSize()
449 | screen_center = QApplication.desktop().screenGeometry()
450 | #居中x和y的值计算与我想的不一样
451 | #原因:question在exec之前无法准确的获取其size。(485,170)是exec之后的实际size。
452 | question.move(((screen_center.width() - 485)/2), ((screen_center.height() - 170)/2))
453 | # question.move((screen_center.width() / 2 - question.width()), (screen_center.height() /2 - question.height()))
454 | # print('screen x:%d,y:%d; question x:%d,y:%d; question width:%d,height:%d.' % (screen_center.width(), screen_center.height(), question.geometry().width(), question.geometry().height(), question.width(), question.height()))
455 | # question.move(QApplication.desktop().screenGeometry().center()- self.rect().center())
456 | ret = question.exec()
457 |
458 | '''
459 | 窗体事件
460 | '''
461 | def eventFilter(self, obj, event):
462 |
463 | etype=event.type()
464 | # print('e type: %s' % etype)
465 | # print('obj is window? %s' % (isinstance(obj,RecordWindow)))
466 | # print('deactivate type id :%d' % QEvent.WindowDeactivate)
467 | if etype == QEvent.WindowDeactivate:
468 | print('丢失焦点')
469 | #代码功能:当窗口失去焦点(不是键盘事件的焦点),窗体隐藏。
470 | #引起的问题:当关闭从此窗口弹出的提示框和子窗口时,此窗口异常退出。
471 | #原因分析:提示框和子窗口在弹出时,引发WindowDeactivate事件主窗口同时隐藏,
472 | #当提示框和子窗口关闭时,因为父窗口已隐藏子窗口似乎是找不到父窗口,或者猜测是误以为父窗口不存在,然后整个应用随即退出。
473 | #解决方案1(先用):用变量need_hide(bool)来控制是否需要隐藏窗体,need_hide=True才隐藏窗体。在打开子窗口和弹出提示窗之前将need_hide=False。
474 | #缺陷:快捷键操作仍然会有同样的问题,因为窗体大多时候是隐藏的。(考虑:把快捷键监控放在托盘图标上?)
475 | #更好的解决方案:1.为什么当父窗口是隐藏状态,子窗口关闭,整个应用也随之退出?(关键)
476 | #2.对窗体事件有更准确的了解,换一种更好的方式来实现窗体失去焦点隐藏主窗体。
477 | #最终解决方案:1.设置QApplication.setQuitOnLastWindowClosed(False)
478 | #2显示逻辑:由此处和RecordTrayIcon.actived事件分别控制,此处负责隐藏;RecordTrayIcon根据此窗体隐藏状态做判断:如果隐藏则显示(即单击或双击显示),
479 | #如果非隐藏但不是activeWindow,则设置activeWindow=True,否则隐藏。
480 |
481 | self.setVisible(False)
482 | # if self.need_hide:
483 | # self.setVisible(False)
484 | # pass
485 | # else:
486 | # self.need_hide = True
487 |
488 | return False
489 |
490 | if __name__ == '__main__':
491 | app = QtWidgets.QApplication(sys.argv)
492 | #当这个属性为True,应用程序会在最后一个可见窗口关闭时退出。
493 | app.setQuitOnLastWindowClosed(False)
494 | screen = app.desktop().screenGeometry()
495 | resolution = '{}x{}'.format(screen.width(), screen.height())
496 | rw = RecordWindow(screen_resolution=resolution)
497 | rw.monitor_shortcut()
498 | rw.rti.show()
499 | rw.show()
500 | sys.exit(app.exec_())
--------------------------------------------------------------------------------
/RunCMD.py:
--------------------------------------------------------------------------------
1 | import subprocess,os,sys
2 |
3 | def run_cmd(cmd, shell = True, universal_newlines = False):
4 | output_info=[]
5 | output_err=[]
6 | cmd = os.path.join(get_ffmpeg_path(), cmd)
7 | print('执行cmd:\n%s' % cmd)
8 | with subprocess.Popen(cmd,
9 | shell = shell,
10 | universal_newlines = universal_newlines,
11 | stdout = subprocess.PIPE,
12 | stdin = subprocess.PIPE,
13 | stderr = subprocess.PIPE
14 | ) as p:
15 | while True:
16 | info=p.stdout.read()
17 | # print(dir(p.stderr))
18 | print(info)
19 | err=p.stderr.read()
20 | print(err)
21 | # if not info and not err:
22 | if info == b'' and err == b'':
23 | if p.poll() is not None:
24 | break
25 | else:
26 | output_info.append(info)
27 | output_err.append(err)
28 |
29 | return output_err, output_info
30 |
31 |
32 | def get_ffmpeg_path():
33 |
34 | datadir = ''
35 | subdir = os.path.join('ffmpeg-shared','bin')
36 |
37 | if getattr(sys, 'frozen', False):
38 | # The application is frozen
39 | datadir = os.path.dirname(sys.executable)
40 | else:
41 | # The application is not frozen
42 | # Change this bit to match where you store your data files:
43 | datadir = os.path.dirname(__file__)
44 | datadir = os.path.join(datadir, subdir)
45 | datadir = os.path.abspath(datadir)
46 | print(datadir)
47 | #如果存在ffmpeg.exe
48 | if os.path.isfile(os.path.join(datadir, 'ffmpeg.exe')):
49 | return datadir
50 | #兼容环境变量设置
51 | return ''
52 |
53 |
--------------------------------------------------------------------------------
/SettingWindow.py:
--------------------------------------------------------------------------------
1 | from PyQt5 import QtWidgets,QtCore,QtGui
2 | from PyQt5.QtWidgets import QFileDialog
3 | from PyQt5.QtWidgets import *
4 | from PyQt5.QtCore import *
5 | import DevicesInfo
6 | from DevicesInfo import *
7 | import RecordConfig
8 | from RecordConfig import *
9 | from PyQt5.QtWidgets import QMessageBox
10 | import resource
11 | import psutil
12 |
13 | class SettingWindow(QDialog):
14 |
15 |
16 | update_setting = pyqtSignal(bool)
17 | def __init__(self, parent = None):
18 | super(SettingWindow,self).__init__(parent)
19 |
20 | self.changed = False
21 | self.setupUi()
22 | self.load()
23 |
24 | def setupUi(self):
25 | self.setObjectName("SettingWindow")
26 | self.setFixedSize(383, 280)
27 | icon = QtGui.QIcon()
28 | icon.addPixmap(QtGui.QPixmap(":/resource/gutin.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
29 | self.setWindowIcon(icon)
30 | self.tabWidget = QtWidgets.QTabWidget(self)
31 | self.tabWidget.setGeometry(QtCore.QRect(10, 10, 371, 221))
32 | self.tabWidget.setObjectName("tabWidget")
33 | self.tab_device = QtWidgets.QWidget()
34 | self.tab_device.setObjectName("tab_device")
35 | self.gridLayoutWidget_3 = QtWidgets.QWidget(self.tab_device)
36 | self.gridLayoutWidget_3.setGeometry(QtCore.QRect(10, 10, 321, 171))
37 | self.gridLayoutWidget_3.setObjectName("gridLayoutWidget_3")
38 | self.gridLayout_3 = QtWidgets.QGridLayout(self.gridLayoutWidget_3)
39 | self.gridLayout_3.setContentsMargins(0, 0, 0, 0)
40 | self.gridLayout_3.setObjectName("gridLayout_3")
41 | self.label_3 = QtWidgets.QLabel(self.gridLayoutWidget_3)
42 | self.label_3.setLayoutDirection(QtCore.Qt.LeftToRight)
43 | self.label_3.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
44 | self.label_3.setWordWrap(False)
45 | self.label_3.setObjectName("label_3")
46 | self.gridLayout_3.addWidget(self.label_3, 2, 0, 1, 1)
47 | self.cb_camera_devices = QtWidgets.QComboBox(self.gridLayoutWidget_3)
48 | self.cb_camera_devices.setObjectName("devices.camera_device_name")
49 | self.gridLayout_3.addWidget(self.cb_camera_devices, 0, 1, 1, 1)
50 | self.cb_voice_devices = QtWidgets.QComboBox(self.gridLayoutWidget_3)
51 | self.cb_voice_devices.setObjectName("devices.voice_device_name")
52 | self.gridLayout_3.addWidget(self.cb_voice_devices, 1, 1, 1, 1)
53 | self.cb_screen_devices = QtWidgets.QComboBox(self.gridLayoutWidget_3)
54 | self.cb_screen_devices.setObjectName("devices.screen_device_name")
55 | self.gridLayout_3.addWidget(self.cb_screen_devices, 2, 1, 1, 1)
56 | self.label_2 = QtWidgets.QLabel(self.gridLayoutWidget_3)
57 | self.label_2.setLayoutDirection(QtCore.Qt.LeftToRight)
58 | self.label_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
59 | self.label_2.setWordWrap(False)
60 | self.label_2.setObjectName("label_2")
61 | self.gridLayout_3.addWidget(self.label_2, 1, 0, 1, 1)
62 | self.label = QtWidgets.QLabel(self.gridLayoutWidget_3)
63 | self.label.setLayoutDirection(QtCore.Qt.RightToLeft)
64 | self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
65 | self.label.setWordWrap(False)
66 | self.label.setObjectName("label")
67 | self.gridLayout_3.addWidget(self.label, 0, 0, 1, 1)
68 | self.label_4 = QtWidgets.QLabel(self.gridLayoutWidget_3)
69 | self.label_4.setLayoutDirection(QtCore.Qt.LeftToRight)
70 | self.label_4.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
71 | self.label_4.setWordWrap(False)
72 | self.label_4.setObjectName("label_4")
73 | self.gridLayout_3.addWidget(self.label_4, 3, 0, 1, 1)
74 | self.cb_system_voice_devices = QtWidgets.QComboBox(self.gridLayoutWidget_3)
75 | self.cb_system_voice_devices.setObjectName("devices.system_voice_device_name")
76 | self.gridLayout_3.addWidget(self.cb_system_voice_devices, 3, 1, 1, 1)
77 | self.tabWidget.addTab(self.tab_device, "")
78 | self.tab_key = QtWidgets.QWidget()
79 | self.tab_key.setObjectName("tab_key")
80 | self.gridLayoutWidget_2 = QtWidgets.QWidget(self.tab_key)
81 | self.gridLayoutWidget_2.setGeometry(QtCore.QRect(10, 10, 321, 121))
82 | self.gridLayoutWidget_2.setObjectName("gridLayoutWidget_2")
83 | self.gridLayout_2 = QtWidgets.QGridLayout(self.gridLayoutWidget_2)
84 | self.gridLayout_2.setContentsMargins(0, 0, 0, 0)
85 | self.gridLayout_2.setObjectName("gridLayout_2")
86 | self.le_start_record_screen_shortcut = QtWidgets.QLineEdit(self.gridLayoutWidget_2)
87 | self.le_start_record_screen_shortcut.setObjectName("shortcut.screen")
88 | self.gridLayout_2.addWidget(self.le_start_record_screen_shortcut, 1, 1, 1, 1)
89 | self.label_10 = QtWidgets.QLabel(self.gridLayoutWidget_2)
90 | self.label_10.setLayoutDirection(QtCore.Qt.RightToLeft)
91 | self.label_10.setTextFormat(QtCore.Qt.AutoText)
92 | self.label_10.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
93 | self.label_10.setObjectName("label_10")
94 | self.gridLayout_2.addWidget(self.label_10, 1, 0, 1, 1)
95 | self.le_start_record_camera_shortcut = QtWidgets.QLineEdit(self.gridLayoutWidget_2)
96 | self.le_start_record_camera_shortcut.setObjectName("shortcut.camera")
97 | self.gridLayout_2.addWidget(self.le_start_record_camera_shortcut, 0, 1, 1, 1)
98 | self.label_9 = QtWidgets.QLabel(self.gridLayoutWidget_2)
99 | self.label_9.setLayoutDirection(QtCore.Qt.RightToLeft)
100 | self.label_9.setTextFormat(QtCore.Qt.AutoText)
101 | self.label_9.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
102 | self.label_9.setObjectName("label_9")
103 | self.gridLayout_2.addWidget(self.label_9, 0, 0, 1, 1)
104 | self.label_11 = QtWidgets.QLabel(self.gridLayoutWidget_2)
105 | self.label_11.setLayoutDirection(QtCore.Qt.RightToLeft)
106 | self.label_11.setTextFormat(QtCore.Qt.AutoText)
107 | self.label_11.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
108 | self.label_11.setObjectName("label_11")
109 | self.gridLayout_2.addWidget(self.label_11, 2, 0, 1, 1)
110 | self.le_start_stop_exit_shortcut = QtWidgets.QLineEdit(self.gridLayoutWidget_2)
111 | self.le_start_stop_exit_shortcut.setObjectName("shortcut.stop")
112 | self.gridLayout_2.addWidget(self.le_start_stop_exit_shortcut, 2, 1, 1, 1)
113 | self.tabWidget.addTab(self.tab_key, "")
114 | self.tab_record = QtWidgets.QWidget()
115 | self.tab_record.setObjectName("tab_record")
116 | self.gridLayoutWidget = QtWidgets.QWidget(self.tab_record)
117 | self.gridLayoutWidget.setGeometry(QtCore.QRect(10, 10, 311, 161))
118 | self.gridLayoutWidget.setObjectName("gridLayoutWidget")
119 | self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
120 | self.gridLayout.setContentsMargins(0, 0, 0, 0)
121 | self.gridLayout.setHorizontalSpacing(0)
122 | self.gridLayout.setVerticalSpacing(16)
123 | self.gridLayout.setObjectName("gridLayout")
124 | self.label_14 = QtWidgets.QLabel(self.gridLayoutWidget)
125 | self.label_14.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
126 | self.label_14.setObjectName("label_14")
127 | self.gridLayout.addWidget(self.label_14, 1, 0, 1, 1)
128 | self.cb_resolution = QtWidgets.QComboBox(self.gridLayoutWidget)
129 | self.cb_resolution.setObjectName("record.resolution")
130 | self.gridLayout.addWidget(self.cb_resolution, 0, 1, 1, 1)
131 | self.cb_vcodec = QtWidgets.QComboBox(self.gridLayoutWidget)
132 | self.cb_vcodec.setObjectName("record.vcodec")
133 | self.gridLayout.addWidget(self.cb_vcodec, 1, 1, 1, 1)
134 | self.dsb_frame_rate = QtWidgets.QDoubleSpinBox(self.gridLayoutWidget)
135 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
136 | sizePolicy.setHorizontalStretch(0)
137 | sizePolicy.setVerticalStretch(0)
138 | sizePolicy.setHeightForWidth(self.dsb_frame_rate.sizePolicy().hasHeightForWidth())
139 | self.dsb_frame_rate.setSizePolicy(sizePolicy)
140 | self.dsb_frame_rate.setObjectName("record.frame_rate")
141 | self.gridLayout.addWidget(self.dsb_frame_rate, 2, 1, 1, 1)
142 | self.label_15 = QtWidgets.QLabel(self.gridLayoutWidget)
143 | self.label_15.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
144 | self.label_15.setObjectName("label_15")
145 | self.gridLayout.addWidget(self.label_15, 2, 0, 1, 1)
146 | self.le_file_path = QtWidgets.QLineEdit(self.gridLayoutWidget)
147 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
148 | sizePolicy.setHorizontalStretch(0)
149 | sizePolicy.setVerticalStretch(0)
150 | sizePolicy.setHeightForWidth(self.le_file_path.sizePolicy().hasHeightForWidth())
151 | self.le_file_path.setSizePolicy(sizePolicy)
152 | self.le_file_path.setObjectName("record.file_dir")
153 | self.gridLayout.addWidget(self.le_file_path, 4, 1, 1, 1)
154 | self.label_13 = QtWidgets.QLabel(self.gridLayoutWidget)
155 | self.label_13.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
156 | self.label_13.setObjectName("label_13")
157 | self.gridLayout.addWidget(self.label_13, 4, 0, 1, 1)
158 | self.label_12 = QtWidgets.QLabel(self.gridLayoutWidget)
159 | self.label_12.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
160 | self.label_12.setObjectName("label_12")
161 | self.gridLayout.addWidget(self.label_12, 0, 0, 1, 1)
162 | self.btn_file_dir = QtWidgets.QToolButton(self.gridLayoutWidget)
163 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
164 | sizePolicy.setHorizontalStretch(0)
165 | sizePolicy.setVerticalStretch(0)
166 | sizePolicy.setHeightForWidth(self.btn_file_dir.sizePolicy().hasHeightForWidth())
167 | self.btn_file_dir.setSizePolicy(sizePolicy)
168 | self.btn_file_dir.setObjectName("btn_file_dir")
169 | self.gridLayout.addWidget(self.btn_file_dir, 4, 2, 1, 1)
170 | self.tabWidget.addTab(self.tab_record, "")
171 | self.frame = QtWidgets.QFrame(self)
172 | self.frame.setGeometry(QtCore.QRect(60, 330, 229, 10))
173 | self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
174 | self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
175 | self.frame.setObjectName("frame")
176 |
177 | self.threads_label = QtWidgets.QLabel(self.gridLayoutWidget)
178 | self.threads_label.setLayoutDirection(QtCore.Qt.LeftToRight)
179 | self.threads_label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
180 | self.threads_label.setObjectName("threads_label")
181 | self.gridLayout.addWidget(self.threads_label, 5, 0, 1, 1)
182 | self.threads_spinBox = QtWidgets.QSpinBox(self.gridLayoutWidget)
183 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
184 | sizePolicy.setHorizontalStretch(0)
185 | sizePolicy.setVerticalStretch(0)
186 | sizePolicy.setHeightForWidth(self.threads_spinBox.sizePolicy().hasHeightForWidth())
187 | self.threads_spinBox.setSizePolicy(sizePolicy)
188 | self.threads_spinBox.setObjectName("record.threads")
189 | self.gridLayout.addWidget(self.threads_spinBox, 5, 1, 1, 1)
190 | self.ckb_adaptive_screen_resolution = QtWidgets.QCheckBox(self.gridLayoutWidget)
191 | self.ckb_adaptive_screen_resolution.setObjectName("ckb_adaptive_screen_resolution")
192 | self.ckb_adaptive_screen_resolution.setStyleSheet("padding-left:10")
193 | self.gridLayout.addWidget(self.ckb_adaptive_screen_resolution, 0, 2, 1, 1)
194 | self.tabWidget.addTab(self.tab_record, "")
195 |
196 | self.save_button = QtWidgets.QPushButton(self)
197 | self.save_button.setGeometry(QtCore.QRect(180, 240, 75, 23))
198 | self.save_button.setObjectName("save_button")
199 | self.cancel_button = QtWidgets.QPushButton(self)
200 | self.cancel_button.setGeometry(QtCore.QRect(270, 240, 75, 23))
201 | self.cancel_button.setObjectName("cancel_button")
202 |
203 | self.retranslateUi()
204 | self.tabWidget.setCurrentIndex(0)
205 | QtCore.QMetaObject.connectSlotsByName(self)
206 |
207 | def retranslateUi(self):
208 | _translate = QtCore.QCoreApplication.translate
209 | self.setWindowTitle(_translate("Form", "设置"))
210 | self.label_3.setText(_translate("Form", "屏幕录制设备:"))
211 | self.label_2.setText(_translate("Form", "声音输入设备:"))
212 | self.label.setText(_translate("Form", "摄像头名称:"))
213 | self.label_4.setText(_translate("Form", "系统声音设备:"))
214 | self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_device), _translate("Form", "设备参数配置"))
215 | self.label_10.setText(_translate("Form", "录制屏幕:"))
216 | self.label_9.setText(_translate("Form", "录制摄像头:"))
217 | self.label_11.setText(_translate("Form", "启动/退出:"))
218 | self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_key), _translate("Form", "快捷键设置"))
219 | self.label_14.setText(_translate("Form", "编码格式:"))
220 | self.label_15.setText(_translate("Form", "帧率:"))
221 | self.label_13.setText(_translate("Form", "文件保存目录:"))
222 | self.label_12.setText(_translate("Form", "分辨率:"))
223 | self.btn_file_dir.setText(_translate("Form", "选择文件目录"))
224 | self.threads_label.setText(_translate("Form", "CPU线程:"))
225 | self.ckb_adaptive_screen_resolution.setText(_translate("Form", "屏幕录制自适应"))
226 | self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_record), _translate("Form", "录制参数"))
227 | self.save_button.setText(_translate("Form", "保存"))
228 | self.cancel_button.setText(_translate("Form", "取消"))
229 |
230 | def load_combobox_data(self, combox, data):
231 | #下拉列表数据加载
232 | for obj in data:
233 | name = obj[0]
234 | value = name
235 | if len(obj) > 1:
236 | value = obj[1]
237 | combox.addItem(name, value)
238 |
239 | def get_key_group_name(self, key_tuple):
240 | return key_tuple.replace(r'(','').replace(r')','')
241 |
242 | def load_config(self):
243 | '''
244 | 加载设置
245 | '''
246 | #设备
247 | video_device_name = self.rc.config.get('devices','camera_device_name')
248 | voice_device_name = self.rc.config.get('devices','voice_device_name')
249 | screen_device_name = self.rc.config.get('devices','screen_device_name')
250 | system_voice_device_name = self.rc.config.get('devices','system_voice_device_name')
251 |
252 | # self.cb_camera_devices.setCurrentIndex(1)
253 | video_cur_index = self.cb_camera_devices.findData(video_device_name)
254 | # print('video name:\n%s\ndevice index:%d' % (video_device_name, video_cur_index))
255 | self.cb_camera_devices.setCurrentIndex(video_cur_index)
256 |
257 | self.cb_voice_devices.setCurrentIndex(self.cb_voice_devices.findData(voice_device_name))
258 | self.cb_screen_devices.setCurrentIndex(self.cb_screen_devices.findData(screen_device_name))
259 | self.cb_system_voice_devices.setCurrentIndex(self.cb_system_voice_devices.findData(system_voice_device_name))
260 |
261 | #快捷键
262 | record_camera_key_group = self.rc.config.get('shortcut','camera')
263 | record_screen_key_group = self.rc.config.get('shortcut','screen')
264 | record_stop_key_group = self.rc.config.get('shortcut','stop')
265 |
266 | record_camera_key_group_name = self.get_key_group_name(record_camera_key_group)
267 | record_screen_key_group_name = self.get_key_group_name(record_screen_key_group)
268 | record_stop_key_group_name = self.get_key_group_name(record_stop_key_group)
269 |
270 | self.le_start_record_camera_shortcut.setText(record_camera_key_group_name)
271 | self.le_start_record_screen_shortcut.setText(record_screen_key_group_name)
272 | self.le_start_stop_exit_shortcut.setText(record_stop_key_group_name)
273 |
274 | #录制参数
275 | record_resolution = self.rc.config.get('record','resolution')
276 | record_vcodec = self.rc.config.get('record','vcodec')
277 | record_frame_rate = self.rc.config.getfloat('record','frame_rate')
278 | record_file_dir = self.rc.config.get('record','file_dir')
279 | record_file_dir = os.path.abspath(record_file_dir)
280 | record_threads = int(self.rc.config.get('record','threads'))
281 | record_adaptive_resolution = self.rc.config.getboolean('record', 'adaptive_screen_resolution')
282 |
283 | self.cb_resolution.setCurrentIndex(self.cb_resolution.findData(record_resolution))
284 | self.ckb_adaptive_screen_resolution.setChecked(record_adaptive_resolution)
285 | self.cb_vcodec.setCurrentIndex(self.cb_vcodec.findData(record_vcodec))
286 | self.dsb_frame_rate.setValue(record_frame_rate)
287 | self.le_file_path.setText(record_file_dir)
288 | self.threads_spinBox.setValue(record_threads)
289 |
290 | def load(self):
291 |
292 | self.rc = RecordConfig()
293 | '''
294 | 数据初始化
295 | '''
296 | #设备
297 | di = DevicesInfo()
298 | #gdigrab
299 | di.video_devices.append(['GDI Grab', 'gdigrab'])
300 | self.load_combobox_data(self.cb_camera_devices, di.video_devices)
301 | self.load_combobox_data(self.cb_screen_devices, di.video_devices)
302 | self.load_combobox_data(self.cb_voice_devices, di.voice_devices)
303 | self.load_combobox_data(self.cb_system_voice_devices, di.voice_devices)
304 |
305 | #录制
306 | resolutions = [
307 | ['1920x1080'],
308 | ['1280x1024'],
309 | ['1024x768'],
310 | ['640x480']
311 | ]
312 |
313 | vcodec = [
314 | ['H.264','libx264'],
315 | ['H.265','libx265'],
316 | ]
317 | self.load_combobox_data(self.cb_resolution, resolutions)
318 | self.load_combobox_data(self.cb_vcodec, vcodec)
319 |
320 | self.dsb_frame_rate.setDecimals(1)
321 | cpu_count = psutil.cpu_count(logical=True)
322 | self.threads_spinBox.setMaximum(cpu_count)
323 |
324 | # print(self.cb_camera_devices.currentData())
325 | # print('视频设备列表:')
326 | # print(di.video_devices)
327 | # print('音频设备列表:')
328 | # print(di.voice_devices)
329 |
330 | self.load_config()
331 |
332 | '''
333 | 关联事件
334 | '''
335 | #设备
336 | self.cb_camera_devices.currentIndexChanged.connect(self.stateChangedEvent)
337 | self.cb_voice_devices.currentIndexChanged.connect(self.stateChangedEvent)
338 | self.cb_screen_devices.currentIndexChanged.connect(self.stateChangedEvent)
339 | self.cb_system_voice_devices.currentIndexChanged.connect(self.stateChangedEvent)
340 |
341 | #快捷键
342 | self.le_start_record_camera_shortcut.textChanged.connect(self.stateChangedEvent)
343 | self.le_start_record_screen_shortcut.textChanged.connect(self.stateChangedEvent)
344 | self.le_start_stop_exit_shortcut.textChanged.connect(self.stateChangedEvent)
345 |
346 | #录制参数
347 | self.cb_resolution.currentIndexChanged.connect(self.stateChangedEvent)
348 | self.cb_vcodec.currentIndexChanged.connect(self.stateChangedEvent)
349 | self.dsb_frame_rate.valueChanged.connect(self.stateChangedEvent)
350 | self.le_file_path.textChanged.connect(self.stateChangedEvent)
351 | self.threads_spinBox.valueChanged.connect(self.stateChangedEvent)
352 | self.ckb_adaptive_screen_resolution.stateChanged.connect(self.stateChangedEvent)
353 | # self.le_start_record_camera_shortcut.keyPressEvent = self.record_keypress
354 | # print(dir(self.le_start_record_camera_shortcut.keyPressEvent))
355 |
356 |
357 | # self.le_file_path.setText()
358 | self.btn_file_dir.clicked.connect(self.file_dir_select)
359 | self.save_button.clicked.connect(self.save_setting)
360 | self.cancel_button.clicked.connect(self.cancel)
361 |
362 | self.update_state()
363 |
364 |
365 | def record_keypress(self, event):
366 | print('text:%s' %event.text())
367 | print('key:%d' % event.key())
368 | print('modifiers: %s' % event.modifiers())
369 | print('nativeVirtualKey:%s' % event.nativeVirtualKey())
370 |
371 | def file_dir_select(self, event):
372 | current_dir = self.le_file_path.text()
373 | # print('current dir:%s' % current_dir)
374 | if not os.path.exists(current_dir):
375 | current_dir = os.path.abspath('.')
376 | selected_dir = QFileDialog.getExistingDirectory(self, '选择录像保存目录', current_dir, QFileDialog.ShowDirsOnly)
377 | if selected_dir and os.path.exists(selected_dir):
378 | self.le_file_path.setText(selected_dir)
379 |
380 | def showSettingWindow(self):
381 | if not self.isVisible():
382 | self.exec_()
383 |
384 | def closeEvent(self, event):
385 | print('changed?%s' % self.changed)
386 | if self.changed:
387 |
388 | self.save_setting()
389 |
390 | question = QMessageBox(self)
391 | question.setText('设置已保存,重新启动软件生效。')
392 | question.setWindowTitle('提示')
393 | question.setIcon(QMessageBox.Question)
394 | question.addButton(QMessageBox.Yes)
395 | question.exec()
396 | print('parent is None?%s' % (self.parent is None))
397 | self.changed = False
398 |
399 | # self.setVisible(False)
400 | # event.ignore()
401 |
402 | def save_setting(self):
403 |
404 |
405 | #获取改动值
406 | #设备
407 | camera_device_name = self.cb_camera_devices.currentData()
408 | voice_device_name = self.cb_voice_devices.currentData()
409 | screen_device_name = self.cb_screen_devices.currentData()
410 | system_voice_device_name = self.cb_system_voice_devices.currentData()
411 | # print(camera_device_name)
412 |
413 | #快捷键
414 | record_camera_key_group_name = self.le_start_record_camera_shortcut.text()
415 | record_screen_key_group_name = self.le_start_record_screen_shortcut.text()
416 | record_stop_key_group_name = self.le_start_stop_exit_shortcut.text()
417 | # print(record_camera_key_group_name)
418 |
419 | #录制
420 | resolution = self.cb_resolution.currentData()
421 | adaptive_screen_resolution = str(self.ckb_adaptive_screen_resolution.isChecked())
422 | video_codec = self.cb_vcodec.currentData()
423 | frame_rate = self.dsb_frame_rate.value()
424 | file_dir = self.le_file_path.text()
425 | threads = self.threads_spinBox.value()
426 | # print(threads)
427 |
428 | #保存
429 | conf = self.rc.config
430 |
431 | devices_section_name = 'devices'
432 | conf.set(devices_section_name,'camera_device_name', camera_device_name)
433 | conf.set(devices_section_name,'voice_device_name', voice_device_name)
434 | conf.set(devices_section_name,'screen_device_name', screen_device_name)
435 | conf.set(devices_section_name,'system_voice_device_name', system_voice_device_name)
436 |
437 | shortcut_section_name = 'shortcut'
438 | conf.set(shortcut_section_name,'camera', record_camera_key_group_name)
439 | conf.set(shortcut_section_name,'screen', record_screen_key_group_name)
440 | conf.set(shortcut_section_name,'stop', record_stop_key_group_name)
441 |
442 | record_section_name = 'record'
443 | conf.set(record_section_name,'resolution', resolution)
444 | conf.set(record_section_name,'adaptive_screen_resolution', adaptive_screen_resolution)
445 | conf.set(record_section_name,'vcodec', video_codec)
446 | conf.set(record_section_name,'frame_rate', str(frame_rate))
447 | conf.set(record_section_name,'file_dir', file_dir)
448 | conf.set(record_section_name,'threads', str(threads))
449 |
450 | self.rc.write()
451 | #通知主窗口更新设置
452 | self.update_setting.emit(self.changed)
453 | self.changed = False
454 | self.update_state()
455 |
456 | def update_state(self):
457 |
458 | self.save_button.setDisabled(not self.changed)
459 | self.cancel_button.setDisabled(not self.changed)
460 |
461 | def cancel(self):
462 | self.load_config()
463 | self.changed=False
464 | self.update_state()
465 |
466 | def setting(self, obj_name, value):
467 |
468 | section = ''
469 | name = ''
470 | if obj_name.find('.') >= 0:
471 | section = obj_name.split('.')[0]
472 | name = obj_name.split('.')[1]
473 | if type(value) == type(''):
474 | value = value.strip()
475 | print('check param in index changed:')
476 | print('section:%s' % section)
477 | print('name:%s' % name )
478 | print('value:%s' % value)
479 |
480 | if self.rc.config.has_option(section, name):
481 |
482 | self.changed = True
483 | self.rc.config.set(section, name, value)
484 | else:
485 | pass
486 | print('not found this section or name.')
487 |
488 | def stateChangedEvent(self, new_value):
489 | print('changed value is :%s' % new_value)
490 | self.changed = True
491 | self.update_state()
492 |
493 |
--------------------------------------------------------------------------------
/Shortcut.py:
--------------------------------------------------------------------------------
1 | import PyHook3
2 | import pythoncom
3 |
4 | class Shortcut():
5 |
6 | global HOTKEYS
7 | global ACTIONS
8 | global KEY_STATUS
9 | global PRESSED_COUNT
10 |
11 | HOTKEYS = {}
12 | ACTIONS = {}
13 | KEY_STATUS = {}
14 | PRESSED_COUNT = {}
15 |
16 | def __init__(self):
17 | pass
18 |
19 | def add(self, key_group_id , key_group, action):
20 | global HOTKEYS
21 | global ACTIONS
22 |
23 | HOTKEYS[key_group_id] = key_group
24 | ACTIONS[key_group_id] = action
25 |
26 | def clear(self):
27 | HOTKEYS.clear()
28 | ACTIONS.clear()
29 |
30 | def KeyDownEvent(self, event):
31 | global KEY_STATUS
32 | global HOTKEYS
33 | global PRESSED_COUNT
34 | global ACTIONS
35 |
36 | #标记状态
37 | KEY_STATUS[event.KeyID] = True
38 | # print('HOTKEYS: \n%s' % HOTKEYS)
39 | # print('KEY DOWN/press key status: \n %s' % KEY_STATUS)
40 |
41 | for action_id, key_group in HOTKEYS.items():
42 | #检查每个按键状态
43 | pressed = True
44 | for i in range(len(key_group)):
45 | key = key_group[i]
46 | if key not in KEY_STATUS:
47 | pressed = False
48 | break
49 |
50 | if pressed:
51 | # if action_id not in PRESSED_COUNT.keys():
52 | # PRESSED_COUNT[action_id] =1
53 | # else:
54 | # PRESSED_COUNT[action_id] +=1
55 | print('match.')
56 | #限制一直按下快捷键 动作执行的次数
57 | if action_id not in PRESSED_COUNT.keys():
58 | action=ACTIONS[action_id]
59 | if action:
60 | action()
61 | PRESSED_COUNT[action_id] =1
62 |
63 |
64 |
65 | return True
66 |
67 | def KeyUpEvent(self, event):
68 | global KEY_STATUS
69 | global HOTKEYS
70 | global PRESSED_COUNT
71 | global ACTIONS
72 |
73 | if event.KeyID in KEY_STATUS.keys():
74 | KEY_STATUS.pop(event.KeyID)
75 | # print('KEY UP/press key status: \n %s' % KEY_STATUS)
76 |
77 | #清空组合按键记录
78 | for action_id, key_group in HOTKEYS.items():
79 | if event.KeyID in key_group:
80 | if action_id in PRESSED_COUNT.keys():
81 | PRESSED_COUNT.pop(action_id)
82 |
83 | return True
84 |
85 | def monitor(self):
86 |
87 | # create the hook mananger
88 | hm = PyHook3.HookManager()
89 | # hm.MouseAllButtonsDown = OnMouseEvent
90 | hm.KeyDown = self.KeyDownEvent
91 | hm.KeyUp = self.KeyUpEvent
92 |
93 | hm.HookKeyboard()
94 | # pythoncom.PumpMessages()
95 |
96 |
--------------------------------------------------------------------------------
/complex_setup.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import traceback
3 | from cx_Freeze import setup, Executable
4 | # import msilib
5 |
6 |
7 |
8 | # Dependencies are automatically detected, but it might need fine tuning.
9 |
10 | def get_windows_text(txt):
11 | # return txt.encode('gbk')
12 | return txt
13 |
14 | #中文需要显式用gbk方式编码
15 | version = '0.2.1'
16 | program_name = u'Gutin谷田会议视频录播管理系统'
17 | program_windows_name = get_windows_text(program_name)
18 | unprogram_windows_name = get_windows_text(u'卸载'+program_name)
19 | program_des = get_windows_text(program_name+u"客户端程序 Ver."+version)
20 | program_icon = "resource/gutin.ico"
21 | work_dir = 'record-gutin'
22 |
23 |
24 | #uuid叫通用唯一识别码,后面再卸载快捷方式中要用到
25 | program_code = 'recordwindow'+version
26 |
27 | #主程序手动命名
28 |
29 | target_name= 'RecordWindow.exe'
30 |
31 | build_exe_options = {
32 |
33 | 'include_files':['resource','ffmpeg-shared'], #包含外围的ini、jpg文件,以及data目录下所有文件,以上所有的文件路径都是相对于cxsetup.py的路径。
34 | # "packages": ["os"], #包含用到的包
35 | # "includes": ["PIL","traceback"],
36 | # "excludes": ["tkinter"], #提出wx里tkinter包
37 | # "path": sys.path, #指定上述的寻找路径
38 | # "icon": program_icon #指定ico文件
39 | };
40 |
41 |
42 |
43 | #快捷方式表,这里定义了三个快捷方式
44 |
45 | shortcut_table = [
46 |
47 |
48 |
49 | #1、桌面快捷方式
50 |
51 | (program_windows_name, # Shortcut
52 |
53 | "DesktopFolder", # Directory_ ,必须在Directory表中
54 |
55 | program_windows_name, # Name
56 |
57 | "TARGETDIR", # Component_,必须在Component表中
58 |
59 | "[TARGETDIR]"+target_name, # Target
60 |
61 | None, # Arguments
62 |
63 | program_des, # Description
64 |
65 | None, # Hotkey
66 |
67 | program_icon, # Icon
68 |
69 | None, # IconIndex
70 |
71 | None, # ShowCmd
72 |
73 | 'TARGETDIR' # WkDir
74 |
75 | ),
76 |
77 |
78 |
79 | #2、开始菜单快捷方式
80 |
81 | (program_windows_name, # Shortcut
82 |
83 | "MenuDir", # Directory_
84 |
85 | program_windows_name, # Name
86 |
87 | "TARGETDIR", # Component_
88 |
89 | "[TARGETDIR]"+target_name, # Target
90 |
91 | None, # Arguments
92 |
93 | program_des, # Description
94 |
95 | None, # Hotkey
96 |
97 | program_icon, # Icon
98 |
99 | None, # IconIndex
100 |
101 | None, # ShowCmd
102 |
103 | 'TARGETDIR' # WkDir
104 |
105 | ),
106 |
107 |
108 |
109 | #3、程序卸载快捷方式
110 |
111 | (unprogram_windows_name, # Shortcut
112 |
113 | "MenuDir", # Directory_
114 |
115 | unprogram_windows_name, # Name
116 |
117 | "TARGETDIR", # Component_
118 |
119 | "[System64Folder]msiexec.exe", # Target
120 |
121 | r"/x"+program_code, # Arguments
122 |
123 | program_des, # Description
124 |
125 | None, # Hotkey
126 |
127 | None, # Icon
128 |
129 | None, # IconIndex
130 |
131 | None, # ShowCmd
132 |
133 | 'TARGETDIR' # WkDir
134 |
135 | )
136 |
137 | ]
138 |
139 |
140 |
141 |
142 |
143 | #手动建设的目录,在这里定义。
144 |
145 | '''
146 |
147 | 自定义目录说明:
148 |
149 | ==============
150 |
151 | 1、3个字段分别为 Directory,Directory_Parent,DefaultDir
152 |
153 | 2、字段1指目录名,可以随意命名,并在后面直接使用
154 |
155 | 3、字段2是指字段1的上级目录,上级目录本身也是需要预先定义,除了某些系统自动定义的目录,譬如桌面快捷方式中使用DesktopFolder
156 |
157 | 参考网址 https://msdn.microsoft.com/en-us/library/aa372452(v=vs.85).aspx
158 |
159 | '''
160 |
161 | directories = [
162 |
163 | ( "ProgramMenuFolder","TARGETDIR","." ),
164 |
165 | ( "MenuDir", "ProgramMenuFolder", work_dir)
166 |
167 | ]
168 |
169 |
170 |
171 | # Now create the table dictionary
172 |
173 | # 也可把directories放到data里。
174 |
175 | '''
176 |
177 | 快捷方式说明:
178 |
179 | ============
180 |
181 | 1、windows的msi安装包文件,本身都带一个install database,包含很多表(用一个Orca软件可以看到)。
182 |
183 | 2、下面的 Directory、Shortcut都是msi数据库中的表,所以冒号前面的名字是固定的(貌似大小写是区分的)。
184 |
185 | 3、data节点其实是扩展很多自定义的东西,譬如前面的directories的配置,其实cxfreeze中代码的内容之一,就是把相关配置数据写入到msi数据库的对应表中
186 |
187 | 参考网址:https://msdn.microsoft.com/en-us/library/aa367441(v=vs.85).aspx
188 |
189 | '''
190 |
191 | msi_data = {#"Directory":directories ,
192 |
193 | "Shortcut": shortcut_table
194 |
195 | }
196 |
197 |
198 |
199 | # Change some default MSI options and specify the use of the above defined tables
200 |
201 | #注意product_code是我扩展的,现有的官网cx_freeze不支持该参数,为此简单修改了cx_freeze包的代码,后面贴上修改的代码。
202 |
203 | bdist_msi_options = {
204 | # 'data': msi_data,
205 | 'add_to_path': False,
206 | 'directories': directories,
207 | 'initial_target_dir': r'[ProgramFilesFolder]\%s' % (work_dir)}
208 |
209 |
210 |
211 |
212 |
213 | # GUI applications require a different base on Windows (the default is for a
214 |
215 | # console application).
216 |
217 | base = None;
218 |
219 | if sys.platform == "win32":
220 |
221 | base = "Win32GUI"
222 |
223 |
224 |
225 | #简易方式定义快捷方式,放到Executeable()里。
226 |
227 | #shortcutName = "AppName",
228 |
229 | #shortcutDir = "ProgramMenuFolder"
230 |
231 | setup(
232 | name = program_windows_name.encode('gbk'),
233 | author='林潇',
234 | version = version,
235 | description = program_des,
236 | options = {"build_exe": build_exe_options,"bdist_msi": bdist_msi_options},
237 | executables = [Executable(
238 | "RecordWindow.py",
239 | targetName= target_name,
240 | base=base,
241 | icon = program_icon)
242 | ])
--------------------------------------------------------------------------------
/csetup.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from cx_Freeze import setup, Executable
3 |
4 | # Dependencies are automatically detected, but it might need fine tuning.
5 | build_exe_options = { 'include_files':['ffmpeg-shared'], 'build_exe' : 'd:/dev/record/record-win'}
6 | install_exe_options = { 'install_dir' : 'd:/dev/record/record-win', 'build_dir':'build', 'install_exe':'d:\\record-camera-and-screen'}
7 |
8 | # GUI applications require a different base on Windows (the default is for a
9 | # console application).
10 | base = None
11 | if sys.platform == "win32":
12 | base = "Win32GUI"
13 |
14 | executables = [
15 | Executable('RecordWindow.py', base=base, icon = 'resource/gutin.ico')
16 | ]
17 | setup( name = "Gutin谷田会议视频录播管理系统",
18 | version = "0.2",
19 | description = "record camera or screen",
20 | options = {"build_exe": build_exe_options},
21 | executables=executables
22 | )
--------------------------------------------------------------------------------
/ffmpeg-shared/LICENSE.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/ffmpeg-shared/README.txt:
--------------------------------------------------------------------------------
1 | Zeranoe FFmpeg Builds
2 |
3 | Build: ffmpeg-20180331-be502ec-win64-shared
4 |
5 | Configuration:
6 | --disable-static
7 | --enable-shared
8 | --enable-gpl
9 | --enable-version3
10 | --enable-sdl2
11 | --enable-bzlib
12 | --enable-fontconfig
13 | --enable-gnutls
14 | --enable-iconv
15 | --enable-libass
16 | --enable-libbluray
17 | --enable-libfreetype
18 | --enable-libmp3lame
19 | --enable-libopencore-amrnb
20 | --enable-libopencore-amrwb
21 | --enable-libopenjpeg
22 | --enable-libopus
23 | --enable-libshine
24 | --enable-libsnappy
25 | --enable-libsoxr
26 | --enable-libtheora
27 | --enable-libtwolame
28 | --enable-libvpx
29 | --enable-libwavpack
30 | --enable-libwebp
31 | --enable-libx264
32 | --enable-libx265
33 | --enable-libxml2
34 | --enable-libzimg
35 | --enable-lzma
36 | --enable-zlib
37 | --enable-gmp
38 | --enable-libvidstab
39 | --enable-libvorbis
40 | --enable-libvo-amrwbenc
41 | --enable-libmysofa
42 | --enable-libspeex
43 | --enable-libxvid
44 | --enable-libaom
45 | --enable-libmfx
46 | --enable-amf
47 | --enable-ffnvcodec
48 | --enable-cuvid
49 | --enable-d3d11va
50 | --enable-nvenc
51 | --enable-nvdec
52 | --enable-dxva2
53 | --enable-avisynth
54 |
55 | Libraries:
56 | SDL 2.0.7
57 | bzip2 1.0.6
58 | Fontconfig 2.12.6
59 | GnuTLS 3.5.18
60 | libiconv 1.15
61 | libass 0.14.0
62 | libbluray 20180123-6021ff9
63 | FreeType 2.9
64 | LAME 3.100
65 | OpenCORE AMR 20170731-07a5be4
66 | OpenJPEG 2.3.0
67 | Opus 1.2.1
68 | shine 3.1.1
69 | Snappy 1.1.7
70 | libsoxr 20160605-5fa7eeb
71 | Theora 1.1.1
72 | TwoLAME 0.3.13
73 | vpx 1.7.0
74 | WavPack 5.1.0
75 | WebP 0.6.1
76 | x264 20180118-7d0ff22
77 | x265 20180323-1fafca2
78 | libxml2 2.9.7
79 | z.lib 20180119-5f24b48
80 | XZ Utils 5.2.3
81 | zlib 1.2.11
82 | GMP 6.1.2
83 | vid.stab 20170830-afc8ea9
84 | Vorbis 1.3.5
85 | VisualOn AMR-WB 20141107-3b3fcd0
86 | libmysofa 20171120-cec6eea
87 | Speex 1.2.0
88 | Xvid 1.3.5
89 | aom 20180330-105e9b1
90 | libmfx 1.23
91 | AMF 20171219-801247d
92 | nv-codec-headers 20180227-12712ab
93 |
94 | Copyright (C) 2018 Kyle Schwarz
95 |
96 | This program is free software: you can redistribute it and/or modify
97 | it under the terms of the GNU General Public License as published by
98 | the Free Software Foundation, either version 3 of the License, or
99 | (at your option) any later version.
100 |
101 | This program is distributed in the hope that it will be useful,
102 | but WITHOUT ANY WARRANTY; without even the implied warranty of
103 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
104 | GNU General Public License for more details.
105 |
106 | You should have received a copy of the GNU General Public License
107 | along with this program. If not, see .
108 |
--------------------------------------------------------------------------------
/ffmpeg-shared/bin/avcodec-58.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/ffmpeg-shared/bin/avcodec-58.dll
--------------------------------------------------------------------------------
/ffmpeg-shared/bin/avdevice-58.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/ffmpeg-shared/bin/avdevice-58.dll
--------------------------------------------------------------------------------
/ffmpeg-shared/bin/avfilter-7.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/ffmpeg-shared/bin/avfilter-7.dll
--------------------------------------------------------------------------------
/ffmpeg-shared/bin/avformat-58.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/ffmpeg-shared/bin/avformat-58.dll
--------------------------------------------------------------------------------
/ffmpeg-shared/bin/avutil-56.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/ffmpeg-shared/bin/avutil-56.dll
--------------------------------------------------------------------------------
/ffmpeg-shared/bin/ffmpeg.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/ffmpeg-shared/bin/ffmpeg.exe
--------------------------------------------------------------------------------
/ffmpeg-shared/bin/ffplay.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/ffmpeg-shared/bin/ffplay.exe
--------------------------------------------------------------------------------
/ffmpeg-shared/bin/ffprobe.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/ffmpeg-shared/bin/ffprobe.exe
--------------------------------------------------------------------------------
/ffmpeg-shared/bin/postproc-55.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/ffmpeg-shared/bin/postproc-55.dll
--------------------------------------------------------------------------------
/ffmpeg-shared/bin/swresample-3.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/ffmpeg-shared/bin/swresample-3.dll
--------------------------------------------------------------------------------
/ffmpeg-shared/bin/swscale-5.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/ffmpeg-shared/bin/swscale-5.dll
--------------------------------------------------------------------------------
/ffmpeg-shared/presets/ffprobe.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
--------------------------------------------------------------------------------
/ffmpeg-shared/presets/libvpx-1080p.ffpreset:
--------------------------------------------------------------------------------
1 | vcodec=libvpx
2 |
3 | g=120
4 | lag-in-frames=16
5 | deadline=good
6 | cpu-used=0
7 | vprofile=1
8 | qmax=51
9 | qmin=11
10 | slices=4
11 | b=2M
12 |
13 | #ignored unless using -pass 2
14 | maxrate=24M
15 | minrate=100k
16 | auto-alt-ref=1
17 | arnr-maxframes=7
18 | arnr-strength=5
19 | arnr-type=centered
20 |
--------------------------------------------------------------------------------
/ffmpeg-shared/presets/libvpx-1080p50_60.ffpreset:
--------------------------------------------------------------------------------
1 | vcodec=libvpx
2 |
3 | g=120
4 | lag-in-frames=25
5 | deadline=good
6 | cpu-used=0
7 | vprofile=1
8 | qmax=51
9 | qmin=11
10 | slices=4
11 | b=2M
12 |
13 | #ignored unless using -pass 2
14 | maxrate=24M
15 | minrate=100k
16 | auto-alt-ref=1
17 | arnr-maxframes=7
18 | arnr-strength=5
19 | arnr-type=centered
20 |
--------------------------------------------------------------------------------
/ffmpeg-shared/presets/libvpx-360p.ffpreset:
--------------------------------------------------------------------------------
1 | vcodec=libvpx
2 |
3 | g=120
4 | lag-in-frames=16
5 | deadline=good
6 | cpu-used=0
7 | vprofile=0
8 | qmax=63
9 | qmin=0
10 | b=768k
11 |
12 | #ignored unless using -pass 2
13 | maxrate=1.5M
14 | minrate=40k
15 | auto-alt-ref=1
16 | arnr-maxframes=7
17 | arnr-strength=5
18 | arnr-type=centered
19 |
--------------------------------------------------------------------------------
/ffmpeg-shared/presets/libvpx-720p.ffpreset:
--------------------------------------------------------------------------------
1 | vcodec=libvpx
2 |
3 | g=120
4 | lag-in-frames=16
5 | deadline=good
6 | cpu-used=0
7 | vprofile=0
8 | qmax=51
9 | qmin=11
10 | slices=4
11 | b=2M
12 |
13 | #ignored unless using -pass 2
14 | maxrate=24M
15 | minrate=100k
16 | auto-alt-ref=1
17 | arnr-maxframes=7
18 | arnr-strength=5
19 | arnr-type=centered
20 |
--------------------------------------------------------------------------------
/ffmpeg-shared/presets/libvpx-720p50_60.ffpreset:
--------------------------------------------------------------------------------
1 | vcodec=libvpx
2 |
3 | g=120
4 | lag-in-frames=25
5 | deadline=good
6 | cpu-used=0
7 | vprofile=0
8 | qmax=51
9 | qmin=11
10 | slices=4
11 | b=2M
12 |
13 | #ignored unless using -pass 2
14 | maxrate=24M
15 | minrate=100k
16 | auto-alt-ref=1
17 | arnr-maxframes=7
18 | arnr-strength=5
19 | arnr-type=centered
20 |
--------------------------------------------------------------------------------
/list_devices_exarct.py:
--------------------------------------------------------------------------------
1 | import re
2 |
3 |
4 | devices_txt = r'''
5 | ffmpeg version N-90553-gbe502ec6cd Copyright (c) 2000-2018 the FFmpeg developers
6 | built with gcc 7.3.0 (GCC)
7 | configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
8 | libavutil 56. 12.100 / 56. 12.100
9 | libavcodec 58. 16.100 / 58. 16.100
10 | libavformat 58. 10.100 / 58. 10.100
11 | libavdevice 58. 2.100 / 58. 2.100
12 | libavfilter 7. 13.100 / 7. 13.100
13 | libswscale 5. 0.102 / 5. 0.102
14 | libswresample 3. 0.101 / 3. 0.101
15 | libpostproc 55. 0.100 / 55. 0.100
16 | [dshow @ 00000166634ef000] DirectShow video devices (some may be both video and audio devices)
17 | [dshow @ 00000166634ef000] "USB2.0 HD UVC WebCam"
18 | [dshow @ 00000166634ef000] Alternative name "@device_pnp_\\?\usb#vid_04f2&pid_b354&mi_00#7&30d7ad30&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
19 | [dshow @ 00000166634ef000] "screen-capture-recorder"
20 | [dshow @ 00000166634ef000] Alternative name "@device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\{4EA69364-2C8A-4AE6-A561-56E4B5044439}"
21 | [dshow @ 00000166634ef000] DirectShow audio devices
22 | [dshow @ 00000166634ef000] "楹﹀厠椋?(Realtek High Definition Audio)"[dshow @ 00000166634ef000] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{571529B3-7DB3-42A3-ADEF-BBD82925C15D}"
23 | [dshow @ 00000166634ef000] "virtual-audio-capturer"
24 | [dshow @ 00000166634ef000] Alternative name "@device_sw_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\{8E146464-DB61-4309-AFA1-3578E927E935}"
25 | dummy: Immediate exit requested
26 | '''
27 |
28 | def get_device_info(text_list):
29 | device_list = []
30 | if text_list and len(text_list) % 2 == 0:
31 | i=0
32 | while i < len(text_list):
33 | step = 2
34 | device = {}
35 | device_name = text_list[i].strip()
36 | device['Name'] = device_name.replace('"','')
37 | alternative_name_text = text_list[i+1]
38 | alter_re = re.search(r'"(.+)"',alternative_name_text)
39 | if alter_re:
40 | device_alternative_name = alter_re.group(1)
41 | device['Alternative'] = device_alternative_name
42 | device_list.append(device)
43 | i+=step
44 | return device_list
45 |
46 |
47 | device_line = []
48 | # print(dir(re))
49 | results = re.findall(r'\[[^\]]+\]([^\[]+)',devices_txt)
50 | # results.pop(0)
51 | video_devices_spos=-1
52 | voice_devices_spos=-1
53 | for i in range(len(results)):
54 | txt = results[i]
55 | print(txt.strip())
56 | if txt.find('DirectShow video devices') >= 0:
57 | video_devices_spos = i
58 | if txt.find('DirectShow audio devices') >=0:
59 | voice_devices_spos = i
60 |
61 | video_devices = get_device_info(results[video_devices_spos+1:voice_devices_spos])
62 | voice_devices = get_device_info(results[voice_devices_spos+1:])
63 |
64 | print('视频设备列表:')
65 | print(video_devices)
66 | print('音频设备列表:')
67 | print(voice_devices)
68 |
69 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | PyQt5
2 | psutil
3 | pyhook3
4 | pywin32
5 | cchardet
--------------------------------------------------------------------------------
/resource.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | resource/gutin.jpg
5 | resource/gutin.ico
6 | resource/start.png
7 | resource/camera_recording_colorful.png
8 | resource/screen_recording.png
9 |
10 |
11 |
--------------------------------------------------------------------------------
/resource/camera_recording.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/resource/camera_recording.png
--------------------------------------------------------------------------------
/resource/camera_recording_colorful.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/resource/camera_recording_colorful.png
--------------------------------------------------------------------------------
/resource/camera_recording_yellow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/resource/camera_recording_yellow.png
--------------------------------------------------------------------------------
/resource/gutin.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/resource/gutin.ico
--------------------------------------------------------------------------------
/resource/gutin.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/resource/gutin.jpg
--------------------------------------------------------------------------------
/resource/screen_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/resource/screen_black.png
--------------------------------------------------------------------------------
/resource/screen_recording.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/resource/screen_recording.png
--------------------------------------------------------------------------------
/resource/start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/resource/start.png
--------------------------------------------------------------------------------
/resource/start_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/resource/start_black.png
--------------------------------------------------------------------------------
/resource/stop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/resource/stop.png
--------------------------------------------------------------------------------
/resource/stop_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/resource/stop_black.png
--------------------------------------------------------------------------------
/setup.iss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/setup.iss
--------------------------------------------------------------------------------
/test/help.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ilinxiao/record-camera-and-screen/4508f29f46f73e5d237d6e2efbb95f97fe5f2b70/test/help.html
--------------------------------------------------------------------------------
/test/read_winreg.py:
--------------------------------------------------------------------------------
1 | # 获取Windows的已打的补丁号
2 | import winreg
3 | from winreg import *
4 | import re
5 | import os
6 | import datetime
7 | import hashlib
8 |
9 | def subRegKey(key, pattern, patchlist):
10 | # 个数
11 | count = QueryInfoKey(key)
12 | for index in range(len(QueryInfoKey(key))):
13 | # 获取标题
14 | name = EnumKey(key, index)
15 |
16 | result = patch.match(name)
17 | if result:
18 | patchlist.append(result.group(1))
19 | sub = OpenKey(key, name)
20 | subRegKey(sub, pattern, patchlist)
21 | CloseKey(sub)
22 |
23 |
24 | def check_run_state():
25 | #验证运行有效性逻辑:
26 | #一、判断是否正常安装
27 | #判断条件:软件安装时在注册表“HKEY_CURRENT_USER\\SOFTWARE\\Gutin\\Record“记录下安装目录
28 | #二、非正常安装有效时间为三个月,且只能发生一次
29 |
30 | #验证当前运行目录是否存在注册表中
31 | qualified = False
32 | run_dir = os.path.abspath('.')
33 | # print('run_dir:%s' % run_dir)
34 | reg_path = 'SOFTWARE\\Gutin\\Record'
35 | feature_name ='InstallDir'
36 | key = OpenKey(HKEY_CURRENT_USER, reg_path, access = KEY_READ)
37 | items = QueryInfoKey(key)
38 | for i in range(items[1]):
39 | item = EnumValue(key, i)
40 | name = item[0]
41 | value = item[1]
42 | type = item[2]
43 | if name and name.find(feature_name)>=0:
44 | if os.path.samefile(value, run_dir):
45 | qualified = True
46 | break;
47 |
48 | if not qualified:
49 | #查找非正常安装目录记录
50 | #记录以运行目录的hash值作为键名,值为首次运行的时间
51 | time_format= '%Y-%m-%d %H:%M:%S'
52 | run_time = None
53 | # run_dir_hash = hashlib.md5(run_dir.encode('utf-8')).hexdigest()
54 | unqualified_key_name = 'Unqualified'
55 | has_unqualified = False
56 | for i in range(items[1]):
57 | item = EnumValue(key, i)
58 | name = item[0]
59 | value = item[1]
60 | type = item[2]
61 | if name == unqualified_key_name:
62 | has_unqualified = True
63 | run_time = value
64 |
65 | if not has_unqualified:
66 | #如果不存在,创建
67 | run_time = datetime.datetime.now().strftime(time_format)
68 | key = OpenKey(HKEY_CURRENT_USER, reg_path, access = KEY_SET_VALUE)
69 | SetValueEx(key, unqualified_key_name, 0, REG_SZ, run_time)
70 |
71 | #判断时限
72 | # now = datetime.datetime.strptime('2018-06-22 12:11:51', time_format)
73 | now = datetime.datetime.now()
74 | run_time_obj = datetime.datetime.strptime(run_time, time_format)
75 | print('first run_time:%s' % run_time)
76 | print('now:%s' % now.strftime(time_format))
77 |
78 | # qual_days = 1 - (now - run_time_obj).days
79 | # print('qualified days:%d' % (qual_days))
80 | print('qualified hours:%d' % (((now - run_time_obj).total_seconds())//3600))
81 | qual_hours = 18 - ((now - run_time_obj).total_seconds())//3600
82 | # if qual_days > 0:
83 | if qual_hours > 0:
84 | qualified = True
85 |
86 | CloseKey(key)
87 | return qualified
88 |
89 |
90 | if __name__ == '__main__':
91 | # patchlist = []
92 | # updates = 'SOFTWARE\\Gutin\\Record'
93 | # patch = re.compile('InstallDir.+')
94 | # key = OpenKey(HKEY_CURRENT_USER, updates, access = KEY_READ)
95 | # items = QueryInfoKey(key)
96 | # print(items[1])
97 | # for i in range(items[1]):
98 | # item = EnumValue(key, i)
99 | # name = item[0]
100 | # value = item[1]
101 | # type = item[2]
102 | # if name and name.find('InstallDir')>=0:
103 | # print(item)
104 |
105 | print(check_run_state())
106 |
107 | # print(items)
108 | # CloseKey(key)
--------------------------------------------------------------------------------