yuka-friends / Windrecorder

Windrecorder is a memory search app by records everything on your screen in small size, to let you rewind what you have seen, query through OCR text or image description, and get activity statistics.
GNU General Public License v2.0
3k stars 130 forks source link

偶尔 Recording 会停滞不动,webui 显示“当前未在录制屏幕”,疑似 ffmpeg 进程异常退出 #60

Closed Antonoko closed 11 months ago

Antonoko commented 11 months ago

偶尔 Recording 会停滞不动,webui 显示当前未在录制屏幕。 请刷新查看最新运行状态。,日志如下,但此时并没有爆内存,长时间不动或正常使用都偶尔会遇到这种情况,需要重启脚本才行。

frame= 1703 fps=1.9 q=0.0 size=    2048kB time=00:14:10.00 bitrate=  19.7[out#0/mp4 @ 000001f18f278dc0] video:2160kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.659762%
frame= 1800 fps=2.0 q=-1.0 Lsize=    2174kB time=00:14:58.50 bitrate=  19.8kbits/s speed=0.998x
[libx264 @ 000001f190dbe180] frame I:4     Avg QP: 1.50  size:293220
[libx264 @ 000001f190dbe180] frame P:205   Avg QP: 0.36  size:  2668
[libx264 @ 000001f190dbe180] frame B:1591  Avg QP: 0.56  size:   309
[libx264 @ 000001f190dbe180] consecutive B-frames:  0.3%  0.2%  0.2%  0.2%  0.3%  0.0%  0.8%  0.0% 98.0%
[libx264 @ 000001f190dbe180] mb I  I16..4: 59.3% 33.9%  6.8%
[libx264 @ 000001f190dbe180] mb P  I16..4:  0.5%  0.0%  0.0%  P16..4:  0.4%  0.0%  0.0%  0.0%  0.0%    skip:99.0%
[libx264 @ 000001f190dbe180] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.0%  0.0%  0.0%  direct: 0.0%  skip:100.0%  L0:40.4% L1:59.5% BI: 0.0%
[libx264 @ 000001f190dbe180] final ratefactor: -12.27
[libx264 @ 000001f190dbe180] 8x8 transform intra:27.2% inter:75.7%
[libx264 @ 000001f190dbe180] coded y,u,v intra: 11.8% 8.2% 6.9% inter: 0.0% 0.0% 0.0%
[libx264 @ 000001f190dbe180] i16 v,h,dc,p: 93%  3%  3%  1%
[libx264 @ 000001f190dbe180] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10%  8% 81%  1%  0%  0%  0%  0%  0%
[libx264 @ 000001f190dbe180] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 18% 15% 18%  4%  3%  3%  5%  3%
[libx264 @ 000001f190dbe180] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000001f190dbe180] ref P L0: 92.0%  0.4%  3.7%  3.9%
[libx264 @ 000001f190dbe180] ref B L0: 74.4% 24.1%  1.6%
[libx264 @ 000001f190dbe180] ref B L1: 97.4%  2.6%
[libx264 @ 000001f190dbe180] kb/s:19.65

Originally posted by @ASC8384 in https://github.com/yuka-friends/Windrecorder/issues/54#issuecomment-1842461795

@ASC8384 hi,当停滞不动时,任务管理器中可以找到 ffmpeg 进程吗?webui 中的检测选项会检测是否有 ffmpeg 进程正在运行,若无,可能是遇到了异常情况导致 ffmpeg 被退出了。

改进:录制过程中检测 ffmpeg 是否仍在正常执行,若无则重启进程。

ASC8384 commented 11 months ago

任务管理器中找不到 ffmpeg 进程

以下是最新停滞的日志:

Inconsistent content
Writing to database.
_____________________
processing IMG - OCR:1768.jpg
maintainManager: OCR text by chineseOCRlite
[out#0/mp4 @ 00000230ac0f8dc0] video:1376kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.032061%
frame= 1800 fps=2.0 q=-1.0 Lsize=    1390kB time=00:14:58.50 bitrate=  12.7kbits/s speed=0.998x
[libx264 @ 00000230add2e180] frame I:3     Avg QP: 3.27  size:107107
[libx264 @ 00000230add2e180] frame P:201   Avg QP: 0.81  size:  3304
[libx264 @ 00000230add2e180] frame B:1596  Avg QP: 1.24  size:   265
[libx264 @ 00000230add2e180] consecutive B-frames:  0.2%  0.0%  0.0%  0.0%  0.8%  0.0%  0.0%  0.0% 99.0%
[libx264 @ 00000230add2e180] mb I  I16..4: 76.5% 20.0%  3.5%
[libx264 @ 00000230add2e180] mb P  I16..4:  0.4%  0.0%  0.0%  P16..4:  0.7%  0.1%  0.1%  0.0%  0.0%    skip:98.8%
[libx264 @ 00000230add2e180] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.1%  0.0%  0.0%  direct: 0.0%  skip:99.9%  L0:25.1% L1:74.9% BI: 0.0%
[libx264 @ 00000230add2e180] final ratefactor: -1.64
[libx264 @ 00000230add2e180] 8x8 transform intra:16.4% inter:47.6%
[libx264 @ 00000230add2e180] coded y,u,v intra: 10.9% 6.7% 5.2% inter: 0.0% 0.0% 0.0%
[libx264 @ 00000230add2e180] i16 v,h,dc,p: 93%  3%  2%  2%
[libx264 @ 00000230add2e180] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 37% 23% 22%  9%  2%  2%  1%  3%  2%
[libx264 @ 00000230add2e180] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 35% 20% 16% 11%  6%  4%  3%  3%  2%
[libx264 @ 00000230add2e180] Weighted P-Frames: Y:0.5% UV:0.5%
[libx264 @ 00000230add2e180] ref P L0: 91.1%  0.2%  7.7%  1.1%
[libx264 @ 00000230add2e180] ref B L0: 89.7% 10.3%  0.0%
[libx264 @ 00000230add2e180] ref B L1: 98.8%  1.2%
[libx264 @ 00000230add2e180] kb/s:12.52
ASC8384 commented 11 months ago

https://github.com/yuka-friends/Windrecorder/blob/33a2e8e28dae66d385f830caa2f7bc7c49afc766/record_screen.py#L277C1-L280C62

哪怕使用该代码,一天依旧会崩溃几次,但频率确实比之前的低多了

Antonoko commented 11 months ago

奇妙的很… 我这边最长程序可以连续 uptime 运行两周,在运行过程中杀掉 ffmpeg 也会自动重启录制线程。

也可以试试分支(虽然理论上也许不会改善?):https://github.com/yuka-friends/Windrecorder/pull/46

(据说日志功能也在路上了)

cc @ShellBin 金牌技术员姐姐看看有什么可能性排查

ASC8384 commented 11 months ago

会不会是 chineseOCRlite 的原因? 配置是 i9-13900K + 64G

ASC8384 commented 11 months ago

攒了 20 多个视频后再索引后,把start_webui.bat搞崩了。

ocr_manager: Calculate the coincidence rate of two results
overlap:97.97101449275362
The coincidence rate exceeds the threshold.
[Skip] The content is consistent, not written to the database, skipped.
_____________________
processing IMG - OCR:1696.jpg
ocr_manager: OCR text by chineseOCRlite
ocr_manager: ocr_sentence_result:
ocr_manager: Calculate the coincidence rate of two results
overlap:14.164305949008499
The coincidence rate does not exceed the threshold.
Inconsistent content
Writing to database.
_____________________
processing IMG - OCR:1704.jpg
ocr_manager: OCR text by chineseOCRlite
请按任意键继续. . .    
Antonoko commented 11 months ago

还真说不定是(不知道!)自从设置入口移除后就没用过 chineseOCRlite 了,未来再封下接口试试替换为 paddleOCR 之类的吧(挖坑)