BodyBalanceEvaluation/backend/_test_rec.py
zhengsl d91af11b7d 修复录屏0字节问题,支持压力板多厂家切换
- 录屏: 高DPI缩放导致奇数尺寸触发libx264编码失败,宽高取偶; ffmpeg stderr写入日志

- 压力板: 新增 pressure_manager_small.py 原厂家小压力板,与现有大压力板并存

- 打包: 新增 build_backend.ps1,更新 requirements_build.txt / config.ini

- 前端: Electron 本地化配置
2026-08-11 18:17:13 +08:00

41 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
"""临时诊断脚本:以奇数尺寸 1707x1067 验证取偶修复"""
import os
import sys
import time
import subprocess
os.chdir(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from devices.screen_recorder import RecordingManager
mgr = RecordingManager()
print('screen_size:', mgr.screen_size, flush=True)
r = mgr.start_recording_ffmpeg('TEST_SESSION', 'TEST_PATIENT', [0, 0, 1707, 1067])
print('start result:', r, flush=True)
for i in range(5):
time.sleep(2)
proc = mgr._ffmpeg_processes.get('screen')
alive = proc.poll() if proc else 'no-proc'
print(f'[{i}] proc.poll={alive}', flush=True)
rr = mgr.stop_recording_ffmpeg('TEST_SESSION')
print('stop result:', rr, flush=True)
time.sleep(1)
base = mgr._ffmpeg_meta.get('screen') or {}
base_path = base.get('base_path')
if base_path:
for f in sorted(os.listdir(base_path)):
p = os.path.join(base_path, f)
print(f'FILE: {f} size={os.path.getsize(p)}', flush=True)
log = os.path.join(base_path, 'ffmpeg_screen.log')
if os.path.exists(log):
print('--- ffmpeg_screen.log ---', flush=True)
with open(log, 'r', encoding='utf-8', errors='ignore') as fh:
print(fh.read()[-2000:], flush=True)
print('DONE', flush=True)