fix(mediainfo): 分辨率判定改为宽高综合,修正 4K 裁切片源被误标 1080p
- 原逻辑只看高度(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 ✅
This commit is contained in:
@@ -9,6 +9,19 @@ class MediaInfoService:
|
|||||||
def get_info(file_path: Path):
|
def get_info(file_path: Path):
|
||||||
return {}
|
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
|
@staticmethod
|
||||||
def get_scene_tags(f_path: Path):
|
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'), {})
|
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
|
w = int(v_stream.get('width') or 0)
|
||||||
|
h = int(v_stream.get('height') or 1080)
|
||||||
if (h > 2000 and mbps > config.REMUX_BITRATE_4K) or (h <= 2000 and mbps > config.REMUX_BITRATE_1080P):
|
|
||||||
tags['is_remux'] = True
|
|
||||||
|
|
||||||
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', '')
|
codec_name = v_stream.get('codec_name', '')
|
||||||
if '265' in codec_name or 'hevc' in codec_name:
|
if '265' in codec_name or 'hevc' in codec_name:
|
||||||
|
|||||||
Reference in New Issue
Block a user