refactor(config): 设备能力/外部服务/阈值等硬编码收敛到 config.ini(P0+P1)
This commit is contained in:
@@ -37,17 +37,13 @@ class PreflightResult:
|
||||
class PreflightService:
|
||||
"""ffprobe 体检 + 补 AC3 音轨 + 报告输出。"""
|
||||
|
||||
# 电视(Amlogic S905X3 + Jellyfin Android TV 0.20)实测可直传的编码
|
||||
# 电视(Amlogic S905X3 + Jellyfin Android TV)实测可解码的编码:
|
||||
# HEVC / H.264 / VC-1(的士速递4 实测 DirectPlay)/ MPEG-2(功夫、非洲和尚实测 DirectPlay)
|
||||
# MPEG-4 实测被转码(花儿与少年 S03),故不列入
|
||||
VIDEO_OK = {"hevc", "h264", "vc1", "mpeg2video"}
|
||||
SUB_OK = {
|
||||
"ass", "ssa", "subrip", "srt", "webvtt", "mov_text",
|
||||
"hdmv_pgs_subtitle", "dvd_subtitle", "dvb_subtitle", "idx",
|
||||
}
|
||||
HDR_TRANSFERS = {"smpte2084", "arib-std-b67"}
|
||||
ASS_OK = {"ass", "ssa"}
|
||||
# 电视能力边界全部来自 config.ini [Compatibility]:
|
||||
# direct_video_codecs / direct_sub_codecs / ass_codecs / hdr_transfers
|
||||
# direct_containers / max_height
|
||||
# 换电视或换播放器时改配置即可,不用动代码。
|
||||
# 历史实测(Amlogic S905X3 + Jellyfin Android TV):
|
||||
# HEVC / H.264 / VC-1(的士速递4)/ MPEG-2(功夫、非洲和尚)可 DirectPlay;
|
||||
# MPEG-4 实测被转码(花儿与少年 S03),故缺省不列入。
|
||||
|
||||
# ------------------------------------------------------------------ 评估
|
||||
|
||||
@@ -125,22 +121,22 @@ class PreflightService:
|
||||
r.info.update(
|
||||
codec=codec, width=width, height=height, level=level,
|
||||
mbps=round(mbps, 1), dv_profile=dv_profile,
|
||||
hdr=transfer in cls.HDR_TRANSFERS, color_transfer=transfer,
|
||||
hdr=transfer in config.HDR_TRANSFERS, color_transfer=transfer,
|
||||
size_gb=round(size_gb, 1), audio=audios, subs=subs,
|
||||
duration=int(float(fmt.get("duration") or 0)),
|
||||
)
|
||||
|
||||
# 1. 容器
|
||||
if path.suffix.lower() not in {".mkv", ".mp4"}:
|
||||
if path.suffix.lower() not in config.DIRECT_CONTAINERS:
|
||||
cls._raise(r, TRANSCODE, f"容器 {path.suffix} 需重新封装或转码")
|
||||
r.actions.append("server_transcode")
|
||||
# 2. 视频编码
|
||||
if codec not in cls.VIDEO_OK:
|
||||
if codec not in config.DIRECT_VIDEO_CODECS:
|
||||
cls._raise(r, TRANSCODE, f"视频编码 {codec} 电视无法解码,需服务端转码")
|
||||
r.actions.append("server_transcode")
|
||||
# 3. 分辨率
|
||||
if height > 2160:
|
||||
cls._raise(r, TRANSCODE, f"{height}p 超过 4K,需服务端缩放转码")
|
||||
if height > config.MAX_HEIGHT:
|
||||
cls._raise(r, TRANSCODE, f"{height}p 超过 {config.MAX_HEIGHT}p,需服务端缩放转码")
|
||||
r.actions.append("server_transcode")
|
||||
# 4. HEVC level(153 = 5.1):仅提示,很多片源 tag 偏高但实际能解
|
||||
if codec == "hevc" and isinstance(level, int) and level > 153:
|
||||
@@ -159,11 +155,11 @@ class PreflightService:
|
||||
# 7. 音频:只记录,不参与判定(默认音轨保持原样,音频是否转码交给 Jellyfin)
|
||||
# 8. 字幕编码
|
||||
# 8. 字幕编码
|
||||
bad = [s["codec"] for s in subs if s["codec"] not in cls.SUB_OK]
|
||||
bad = [s["codec"] for s in subs if s["codec"] not in config.DIRECT_SUB_CODECS]
|
||||
if bad:
|
||||
r.reasons.append(f"未知字幕编码: {sorted(set(bad))}")
|
||||
# 9. 大文件内嵌 ASS:客户端首次播放要现场抽取,会超时
|
||||
has_ass = any(s["codec"] in cls.ASS_OK for s in subs)
|
||||
has_ass = any(s["codec"] in config.ASS_CODECS for s in subs)
|
||||
if has_ass and size_gb > config.PRE_EXTRACT_ASS_GB and 'ass' not in config.SUBTITLE_EXPORT:
|
||||
cls._raise(r, PREP, f"内嵌 ASS + {size_gb:.0f}GB 大文件,需提前抽外挂")
|
||||
r.actions.append("extract_ass")
|
||||
|
||||
Reference in New Issue
Block a user