Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

录屏软件

Windows 屏幕 + 系统声音录制工具。启动即录,托盘图标驻留,右键退出停止。

快速开始

  1. 双击 ScreenRecorder.exe
  2. 右下角出现红色托盘图标 → 录屏已开始
  3. 鼠标悬停图标查看录制时长
  4. 右键图标 → 退出 → 停止录制,视频自动保存
ScreenRecorder.exe
├── config.yaml         ← 首次运行自动生成,修改参数
├── recordings/         ← 录屏文件
│   ├── 2026-08-04_14-30-00.mp4
│   └── screen_recorder.log

配置

编辑 EXE 旁边的 config.yaml,重启生效:

recording:
  fps: 5          # 帧率 1-30,越低文件越小
  audio: true     # 系统声音录制

output:
  dir: "."        # 输出目录(. = EXE 所在目录)

startup: true     # 开机自启

retention_days: 30  # 自动删除 N 天前的录屏(0 = 永不过期)

文件大小参考(4K 主显示器)

fps 每小时 每 10 小时
5 ~600 MB ~6 GB
10 ~1.2 GB ~12 GB
30 ~3.6 GB ~36 GB

命令行参数

ScreenRecorder.exe --fps 10              # 指定帧率
ScreenRecorder.exe --no-audio            # 仅录屏幕
ScreenRecorder.exe --output-dir D:\视# 指定输出目录
ScreenRecorder.exe --duration 3600       # 定时 1 小时自动停止
ScreenRecorder.exe --startup off         # 取消开机自启

CLI 参数优先于 config.yaml

架构

mss 采集屏幕 (GDI)
    │
    ▼
ffmpeg pipe 编码 (libx264 + frag_keyframe+empty_moov)
    │
    ▼
.video_{pid}.mp4 ── remux ──→ 2026-08-04_14-30-00.mp4

recap audio_only (WASAPI loopback)
    │
    ▼
.audio_{pid}.wav ── 有效则合并 ──→ 2026-08-04_14-30-00.mp4

关键设计

问题 方案
突然关机 frag_keyframe+empty_moov → 崩溃可播
音频录制失败 视频和音频完全分开,音频失败不影响视频
残留恢复 启动时扫描 .video_* → remux → _recovered.mp4
过期清理 文件名解析日期,到期自动删除
单实例 CreateMutexW 防重复运行
开机自启 注册表 HKCU\...\Run

代码结构

src/main.py          # 主程序(全部逻辑)
  setup_logging()    # 日志配置
  get_ffmpeg_path()  # 定位内嵌 ffmpeg.exe
  load_config()      # 加载/生成 config.yaml
  recover_temp_files()  # 恢复崩溃残留
  cleanup_old_recordings()  # 清理过期录屏
  RecorderEngine     # 录制引擎(mss + ffmpeg + recap 音频)
  main()             # 入口(托盘图标 + 主循环)

依赖

mss              # 屏幕采集 (GDI BitBlt)
recap-capture    # 系统音频 (WASAPI loopback)
pystray + Pillow # 托盘图标
PyYAML           # 配置文件
numpy            # 帧数据处理
pyinstaller      # 打包

构建

pip install -r requirements.txt
python src/download_ffmpeg.py   # 下载 ffmpeg-master-latest-win64-gpl
build.bat                       # 打包 → dist/ScreenRecorder.exe (~82MB)

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages