Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

chore(integration): 协同扫描控制与媒体诊断

longmeidao6a9afd34feab
diff --cc docs/STATUS.md
index a078a66ad,72c8def8a..019ba5d35
--- a/docs/STATUS.md
+++ b/docs/STATUS.md
@@@ -33,7 -33,7 +33,7 @@@
- Python 最低与默认 3.14;Windows FFmpeg/ffprobe 在 `peach-data/tools/ffmpeg`,macOS 走 PATH。
- amane 0.20.0,安装一致;[功能与接入](reference-snapshots/upstream-review.md)。
- 发行名 `peach`、目录名 `peach-app`;Mac 维护与重启见待办 26。
- - 扫描任务卡支持暂停、三档速度、估时与步骤勾选;无进展预警 120 秒,资料/封面超时 90/240 秒。
-- 扫描/采集无进展 120 秒预警;资料 90 秒、封面 240 秒超时可重试;[诊断与 AV1 核验](DIAGNOSTICS_AUDIT.md)。
++- 扫描卡:暂停、三档速度、估时、步骤;120 秒无进展预警,资料/封面超时 90/240 秒;[诊断](DIAGNOSTICS_AUDIT.md)。
- 资料逐项提交,页面按结果版本刷新;女优资料后继每轮存量至多 16 条。
- 下载后处理:16 条旧失败任务保留,部分资产已移动;`task_run` 外键异常 242 条未清理。
- [标签归一](reference-snapshots/tag-vocabulary-audit.md)
diff --cc src/peach/frame_capture.py
index ddd4d6be7,a699460a1..442faeb40
--- a/src/peach/frame_capture.py
+++ b/src/peach/frame_capture.py
@@@ -11,8 -11,19 +11,20 @@@ import o
import re
import subprocess
from pathlib import Path
+from .processing_control import checkpoint, ffmpeg_options
+ from PIL import Image
+
+
+ def _readable_image(path: Path) -> bool:
+ """图片须完整可解码;纯色 JPEG 也算有效画面。"""
+ try:
+ with Image.open(path) as image:
+ image.load()
+ return image.width > 0 and image.height > 0
+ except (OSError, ValueError, Image.DecompressionBombError):
+ return False
+
#: 部分网盘视频把色彩原色写成 reserved(非法值),swscale 会拒绝缩放;声明为 bt709
#: 只是覆盖坏的元数据,不改动像素。
COLOR_OVERRIDE = ["-color_primaries", "bt709", "-color_trc", "bt709", "-colorspace", "bt709"]
@@@ -34,9 -45,8 +46,10 @@@ def capture_frame(ffmpeg: str, path: st
`-ss` 在 `-i` 之前:那是输入端 seek,只解目标附近的帧。放到后面就是从头解码到
那个时间点,两小时的片子抽最后一帧要几分钟。
"""
+ destination.unlink(missing_ok=True)
command = [ffmpeg, "-y", "-v", "error", "-rw_timeout", "8000000"]
+ checkpoint('frame')
+ command += ffmpeg_options(filter_option='-filter_threads')
if color_override:
command += COLOR_OVERRIDE
command += [
@@@ -72,13 -107,22 +111,25 @@@ def tile_frames(ffmpeg: str, pattern: s
于是拼出来的图少了后半段,而命令本身照样退出 0。
"""
destination.parent.mkdir(parents=True, exist_ok=True)
+ checkpoint('frame')
+ options = ffmpeg_options(filter_option='-filter_complex_threads')
- subprocess.run(
- [ffmpeg, "-y", "-v", "error", *options, "-i", pattern,
- "-filter_complex", f"tile={int(columns)}x{int(rows)}", "-q:v", "4",
- *ffmpeg_options(), str(destination)],
- capture_output=True, timeout=timeout,
- creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0,
- )
- return destination.is_file() and destination.stat().st_size > 4096
+ destination.unlink(missing_ok=True)
+ from .error_reporting import subprocess_failure
+ try:
+ completed = subprocess.run(
- [ffmpeg, "-y", "-v", "error", "-i", pattern,
- "-filter_complex", f"tile={int(columns)}x{int(rows)}", "-q:v", "4", str(destination)],
++ [ffmpeg, "-y", "-v", "error", *options, "-i", pattern,
++ "-filter_complex", f"tile={int(columns)}x{int(rows)}", "-q:v", "4",
++ *ffmpeg_options(), str(destination)],
+ capture_output=True, timeout=timeout,
+ creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0,
+ )
+ except (OSError, subprocess.TimeoutExpired) as error:
+ destination.unlink(missing_ok=True)
+ subprocess_failure('frame-tile', tool=ffmpeg, error=error, timeout_seconds=timeout)
+ raise
+ ok = completed.returncode == 0 and _readable_image(destination)
+ if not ok:
+ destination.unlink(missing_ok=True)
+ subprocess_failure('frame-tile', tool=ffmpeg, stderr=completed.stderr,
+ returncode=completed.returncode, reason='tile_unavailable')
+ return ok