mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2025-10-23 15:11:08 +00:00
feat(dl): ✨ Enhance hybrid processing to handle HDR10 and DV tracks separately by resolution, Hotfix for -q 2160,1080 both tracks will have Hybrid correctly now.
This commit is contained in:
@@ -907,32 +907,53 @@ class dl:
|
|||||||
|
|
||||||
# Check if we're in hybrid mode
|
# Check if we're in hybrid mode
|
||||||
if any(r == Video.Range.HYBRID for r in range_) and title.tracks.videos:
|
if any(r == Video.Range.HYBRID for r in range_) and title.tracks.videos:
|
||||||
# Hybrid mode: process DV and HDR10 tracks together
|
# Hybrid mode: process DV and HDR10 tracks separately for each resolution
|
||||||
self.log.info("Processing Hybrid HDR10+DV tracks...")
|
self.log.info("Processing Hybrid HDR10+DV tracks...")
|
||||||
|
|
||||||
# Run the hybrid processing
|
# Group video tracks by resolution
|
||||||
Hybrid(title.tracks.videos, self.service)
|
resolutions_processed = set()
|
||||||
|
hdr10_tracks = [v for v in title.tracks.videos if v.range == Video.Range.HDR10]
|
||||||
|
dv_tracks = [v for v in title.tracks.videos if v.range == Video.Range.DV]
|
||||||
|
|
||||||
# After hybrid processing, the output file should be in temp directory
|
for hdr10_track in hdr10_tracks:
|
||||||
hybrid_output_path = config.directories.temp / "HDR10-DV.hevc"
|
resolution = hdr10_track.height
|
||||||
|
if resolution in resolutions_processed:
|
||||||
|
continue
|
||||||
|
resolutions_processed.add(resolution)
|
||||||
|
|
||||||
# Create a single mux task for the hybrid output
|
# Find matching DV track for this resolution (use the lowest DV resolution)
|
||||||
task_description = "Multiplexing Hybrid HDR10+DV"
|
matching_dv = min(dv_tracks, key=lambda v: v.height) if dv_tracks else None
|
||||||
task_id = progress.add_task(f"{task_description}...", total=None, start=False)
|
|
||||||
|
|
||||||
# Create tracks with the hybrid video output
|
if matching_dv:
|
||||||
task_tracks = Tracks(title.tracks) + title.tracks.chapters + title.tracks.attachments
|
# Create track pair for this resolution
|
||||||
|
resolution_tracks = [hdr10_track, matching_dv]
|
||||||
|
|
||||||
# Create a new video track for the hybrid output
|
# Run the hybrid processing for this resolution
|
||||||
# Use the HDR10 track as a template but update its path
|
Hybrid(resolution_tracks, self.service)
|
||||||
hdr10_track = next((v for v in title.tracks.videos if v.range == Video.Range.HDR10), None)
|
|
||||||
if hdr10_track:
|
|
||||||
hybrid_track = deepcopy(hdr10_track)
|
|
||||||
hybrid_track.path = hybrid_output_path
|
|
||||||
hybrid_track.range = Video.Range.DV # It's now a DV track
|
|
||||||
task_tracks.videos = [hybrid_track]
|
|
||||||
|
|
||||||
multiplex_tasks.append((task_id, task_tracks))
|
# Create unique output filename for this resolution
|
||||||
|
hybrid_filename = f"HDR10-DV-{resolution}p.hevc"
|
||||||
|
hybrid_output_path = config.directories.temp / hybrid_filename
|
||||||
|
|
||||||
|
# The Hybrid class creates HDR10-DV.hevc, rename it for this resolution
|
||||||
|
default_output = config.directories.temp / "HDR10-DV.hevc"
|
||||||
|
if default_output.exists():
|
||||||
|
shutil.move(str(default_output), str(hybrid_output_path))
|
||||||
|
|
||||||
|
# Create a mux task for this resolution
|
||||||
|
task_description = f"Multiplexing Hybrid HDR10+DV {resolution}p"
|
||||||
|
task_id = progress.add_task(f"{task_description}...", total=None, start=False)
|
||||||
|
|
||||||
|
# Create tracks with the hybrid video output for this resolution
|
||||||
|
task_tracks = Tracks(title.tracks) + title.tracks.chapters + title.tracks.attachments
|
||||||
|
|
||||||
|
# Create a new video track for the hybrid output
|
||||||
|
hybrid_track = deepcopy(hdr10_track)
|
||||||
|
hybrid_track.path = hybrid_output_path
|
||||||
|
hybrid_track.range = Video.Range.DV # It's now a DV track
|
||||||
|
task_tracks.videos = [hybrid_track]
|
||||||
|
|
||||||
|
multiplex_tasks.append((task_id, task_tracks))
|
||||||
else:
|
else:
|
||||||
# Normal mode: process each video track separately
|
# Normal mode: process each video track separately
|
||||||
for video_track in title.tracks.videos or [None]:
|
for video_track in title.tracks.videos or [None]:
|
||||||
|
|||||||
Reference in New Issue
Block a user