From ac789f0a3917010d3a175cae1d213a0a60d8ed98 Mon Sep 17 00:00:00 2001 From: ali Date: Thu, 19 Nov 2026 19:01:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(mediainfo):=20=E5=88=86=E8=BE=A8=E7=8E=87?= =?UTF-8?q?=E5=88=A4=E5=AE=9A=E6=94=B9=E4=B8=BA=E5=AE=BD=E9=AB=98=E7=BB=BC?= =?UTF-8?q?=E5=90=88=EF=BC=8C=E4=BF=AE=E6=AD=A3=204K=20=E8=A3=81=E5=88=87?= =?UTF-8?q?=E7=89=87=E6=BA=90=E8=A2=AB=E8=AF=AF=E6=A0=87=201080p?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 原逻辑只看高度(h>2000 才算 2160p),而 2.39:1 的 4K 片源裁掉黑边后 高度只有 ~1608,被误判成 1080p,命名与 is_remux 阈值跟着错 - 改为宽度优先、高度兜底:w>=3000 或 h>=1600 → 2160p;w>=1700 或 h>=900 → 1080p - 依赖体检缓存统计:库内 4194 个带分辨率标签的文件中,579 个与实测不符 (511 个写 1080p 实为 4K 裁切;68 个写 1080p 实为 1280×720) - 实测:功夫熊猫 (2008) 重命名为 2160p.WEB-DL.HEVC.8bit.AAC.2.0 ✅ --- media/src/services/mediainfo.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/media/src/services/mediainfo.py b/media/src/services/mediainfo.py index eb4722c..0cfd607 100644 --- a/media/src/services/mediainfo.py +++ b/media/src/services/mediainfo.py @@ -9,6 +9,19 @@ class MediaInfoService: def get_info(file_path: Path): return {} + @staticmethod + def classify_resolution(width: int, height: int) -> str: + """按宽高综合判定画质档位。 + + 不能只看高度:2.39:1 的 4K 片源裁掉黑边后高度只有 ~1608, + 用 h>2000 会把 3840×1608 误判成 1080p。宽度才是可靠判据。 + """ + if width >= 3000 or height >= 1600: + return "2160p" + if width >= 1700 or height >= 900: + return "1080p" + return "720p" + @staticmethod def get_scene_tags(f_path: Path): """ @@ -32,12 +45,14 @@ class MediaInfoService: v_stream = next((s for s in data.get('streams', []) if s['codec_type'] == 'video'), {}) - h = int(v_stream.get('height', 1080)) if v_stream.get('height') else 1080 - - if (h > 2000 and mbps > config.REMUX_BITRATE_4K) or (h <= 2000 and mbps > config.REMUX_BITRATE_1080P): - tags['is_remux'] = True + w = int(v_stream.get('width') or 0) + h = int(v_stream.get('height') or 1080) - tags['res'] = "2160p" if h > 2000 else ("1080p" if h > 700 else "720p") + tags['res'] = MediaInfoService.classify_resolution(w, h) + remux_threshold = (config.REMUX_BITRATE_4K if tags['res'] == "2160p" + else config.REMUX_BITRATE_1080P) + if mbps > remux_threshold: + tags['is_remux'] = True codec_name = v_stream.get('codec_name', '') if '265' in codec_name or 'hevc' in codec_name: