fix(naming): improve HDR detection with comprehensive transfer checks and hybrid DV+HDR10 support

HDR10/PQ detection now includes:
- PQ (most common)
- SMPTE ST 2084 (CICP value 16)
- BT.2100
- BT.2020-10
- smpte2084 (lowercase variant)

HLG detection now includes:
- HLG
- Hybrid Log-Gamma
- ARIB STD-B67 (CICP value 18)
- arib-std-b67 (lowercase variant)

Hybrid DV+HDR10 detection:
- Now checks full hdr_format field for both "Dolby Vision" AND
  ("HDR10" OR "SMPTE ST 2086")
- Properly generates filenames like "Movie.2160p.DV HDR H.265.mkv"
- MediaInfo reports: "Dolby Vision / SMPTE ST 2086, HDR10 compatible"

Also adds null safety for transfer characteristics to prevent errors when the field is None.
This commit is contained in:
Andy
2025-11-02 03:19:14 +00:00
parent 6ebdfa8818
commit 597a8b7912
2 changed files with 18 additions and 6 deletions

View File

@@ -173,20 +173,26 @@ class Episode(Title):
if primary_video_track: if primary_video_track:
codec = primary_video_track.format codec = primary_video_track.format
hdr_format = primary_video_track.hdr_format_commercial hdr_format = primary_video_track.hdr_format_commercial
hdr_format_full = primary_video_track.hdr_format or ""
trc = ( trc = (
primary_video_track.transfer_characteristics primary_video_track.transfer_characteristics
or primary_video_track.transfer_characteristics_original or primary_video_track.transfer_characteristics_original
or ""
) )
frame_rate = float(primary_video_track.frame_rate) frame_rate = float(primary_video_track.frame_rate)
# Primary HDR format detection
if hdr_format: if hdr_format:
if (primary_video_track.hdr_format or "").startswith("Dolby Vision"): if hdr_format_full.startswith("Dolby Vision"):
name += " DV" name += " DV"
if DYNAMIC_RANGE_MAP.get(hdr_format) and DYNAMIC_RANGE_MAP.get(hdr_format) != "DV": if any(indicator in hdr_format_full for indicator in ["HDR10", "SMPTE ST 2086"]):
name += " HDR" name += " HDR"
else: else:
name += f" {DYNAMIC_RANGE_MAP.get(hdr_format)} " name += f" {DYNAMIC_RANGE_MAP.get(hdr_format)} "
elif trc and "HLG" in trc: elif "HLG" in trc or "Hybrid Log-Gamma" in trc or "ARIB STD-B67" in trc or "arib-std-b67" in trc.lower():
name += " HLG" name += " HLG"
elif any(indicator in trc for indicator in ["PQ", "SMPTE ST 2084", "BT.2100"]) or "smpte2084" in trc.lower() or "bt.2020-10" in trc.lower():
name += " HDR"
if frame_rate > 30: if frame_rate > 30:
name += " HFR" name += " HFR"
name += f" {VIDEO_CODEC_MAP.get(codec, codec)}" name += f" {VIDEO_CODEC_MAP.get(codec, codec)}"

View File

@@ -124,20 +124,26 @@ class Movie(Title):
if primary_video_track: if primary_video_track:
codec = primary_video_track.format codec = primary_video_track.format
hdr_format = primary_video_track.hdr_format_commercial hdr_format = primary_video_track.hdr_format_commercial
hdr_format_full = primary_video_track.hdr_format or ""
trc = ( trc = (
primary_video_track.transfer_characteristics primary_video_track.transfer_characteristics
or primary_video_track.transfer_characteristics_original or primary_video_track.transfer_characteristics_original
or ""
) )
frame_rate = float(primary_video_track.frame_rate) frame_rate = float(primary_video_track.frame_rate)
# Primary HDR format detection
if hdr_format: if hdr_format:
if (primary_video_track.hdr_format or "").startswith("Dolby Vision"): if hdr_format_full.startswith("Dolby Vision"):
name += " DV" name += " DV"
if DYNAMIC_RANGE_MAP.get(hdr_format) and DYNAMIC_RANGE_MAP.get(hdr_format) != "DV": if any(indicator in hdr_format_full for indicator in ["HDR10", "SMPTE ST 2086"]):
name += " HDR" name += " HDR"
else: else:
name += f" {DYNAMIC_RANGE_MAP.get(hdr_format)} " name += f" {DYNAMIC_RANGE_MAP.get(hdr_format)} "
elif trc and "HLG" in trc: elif "HLG" in trc or "Hybrid Log-Gamma" in trc or "ARIB STD-B67" in trc or "arib-std-b67" in trc.lower():
name += " HLG" name += " HLG"
elif any(indicator in trc for indicator in ["PQ", "SMPTE ST 2084", "BT.2100"]) or "smpte2084" in trc.lower() or "bt.2020-10" in trc.lower():
name += " HDR"
if frame_rate > 30: if frame_rate > 30:
name += " HFR" name += " HFR"
name += f" {VIDEO_CODEC_MAP.get(codec, codec)}" name += f" {VIDEO_CODEC_MAP.get(codec, codec)}"