mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-06-10 11:12:13 +00:00
refactor(dl): declare hybrid_base_only flag and extract standalone mux helper
Make the DV-ingredient marker a declared Video attribute (sibling of needs_duration_fix) instead of a runtime-stamped attribute read via getattr, so the flag is explicit and type-checked. Extract mux_video_standalone() to replace the duplicated per-track mux logic shared by the hybrid and normal-mode paths, removing the copy-paste and the getattr probes. Behavior unchanged.
This commit is contained in:
@@ -2484,6 +2484,25 @@ class dl:
|
|||||||
task_tracks = clone_tracks_for_audio(base_tracks, codec_audio_tracks)
|
task_tracks = clone_tracks_for_audio(base_tracks, codec_audio_tracks)
|
||||||
multiplex_tasks.append((task_id, task_tracks, audio_codec))
|
multiplex_tasks.append((task_id, task_tracks, audio_codec))
|
||||||
|
|
||||||
|
def mux_video_standalone(video_track: Optional[Video]) -> None:
|
||||||
|
if video_track and video_track.dv_compatible_bitstream:
|
||||||
|
apply_dv_fixup(video_track)
|
||||||
|
|
||||||
|
task_description = "Multiplexing"
|
||||||
|
if video_track:
|
||||||
|
if len(quality) > 1:
|
||||||
|
task_description += f" {video_track.height}p"
|
||||||
|
if len(range_) > 1:
|
||||||
|
task_description += f" {video_track.range.name}"
|
||||||
|
if len(vcodec) > 1:
|
||||||
|
task_description += f" {video_track.codec.name}"
|
||||||
|
|
||||||
|
task_tracks = Tracks(title.tracks) + title.tracks.chapters + title.tracks.attachments
|
||||||
|
if video_track:
|
||||||
|
task_tracks.videos = [video_track]
|
||||||
|
|
||||||
|
enqueue_mux_tasks(task_description, task_tracks)
|
||||||
|
|
||||||
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:
|
||||||
self.log.info("Processing Hybrid HDR10+DV tracks...")
|
self.log.info("Processing Hybrid HDR10+DV tracks...")
|
||||||
|
|
||||||
@@ -2541,45 +2560,15 @@ class dl:
|
|||||||
|
|
||||||
# Mux every requested range standalone, skipping the ingredient-only DV.
|
# Mux every requested range standalone, skipping the ingredient-only DV.
|
||||||
for video_track in original_videos:
|
for video_track in original_videos:
|
||||||
if getattr(video_track, "hybrid_base_only", False):
|
if video_track.hybrid_base_only:
|
||||||
continue
|
continue
|
||||||
if getattr(video_track, "dv_compatible_bitstream", False):
|
mux_video_standalone(video_track)
|
||||||
apply_dv_fixup(video_track)
|
|
||||||
|
|
||||||
task_description = "Multiplexing"
|
|
||||||
if len(quality) > 1:
|
|
||||||
task_description += f" {video_track.height}p"
|
|
||||||
if len(range_) > 1:
|
|
||||||
task_description += f" {video_track.range.name}"
|
|
||||||
if len(vcodec) > 1:
|
|
||||||
task_description += f" {video_track.codec.name}"
|
|
||||||
|
|
||||||
task_tracks = Tracks(title.tracks) + title.tracks.chapters + title.tracks.attachments
|
|
||||||
task_tracks.videos = [video_track]
|
|
||||||
|
|
||||||
enqueue_mux_tasks(task_description, task_tracks)
|
|
||||||
|
|
||||||
console.print()
|
console.print()
|
||||||
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]:
|
||||||
if video_track and getattr(video_track, "dv_compatible_bitstream", False):
|
mux_video_standalone(video_track)
|
||||||
apply_dv_fixup(video_track)
|
|
||||||
|
|
||||||
task_description = "Multiplexing"
|
|
||||||
if video_track:
|
|
||||||
if len(quality) > 1:
|
|
||||||
task_description += f" {video_track.height}p"
|
|
||||||
if len(range_) > 1:
|
|
||||||
task_description += f" {video_track.range.name}"
|
|
||||||
if len(vcodec) > 1:
|
|
||||||
task_description += f" {video_track.codec.name}"
|
|
||||||
|
|
||||||
task_tracks = Tracks(title.tracks) + title.tracks.chapters + title.tracks.attachments
|
|
||||||
if video_track:
|
|
||||||
task_tracks.videos = [video_track]
|
|
||||||
|
|
||||||
enqueue_mux_tasks(task_description, task_tracks)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with Live(Padding(progress, (0, 5, 1, 5)), console=console):
|
with Live(Padding(progress, (0, 5, 1, 5)), console=console):
|
||||||
|
|||||||
@@ -296,6 +296,7 @@ class Video(Track):
|
|||||||
self.closed_captions: list[dict[str, Any]] = closed_captions or []
|
self.closed_captions: list[dict[str, Any]] = closed_captions or []
|
||||||
self.needs_duration_fix = False
|
self.needs_duration_fix = False
|
||||||
self.dv_compatible_bitstream = dv_compatible_bitstream
|
self.dv_compatible_bitstream = dv_compatible_bitstream
|
||||||
|
self.hybrid_base_only = False
|
||||||
|
|
||||||
def to_dict(self) -> dict[str, Any]:
|
def to_dict(self) -> dict[str, Any]:
|
||||||
data = super().to_dict()
|
data = super().to_dict()
|
||||||
|
|||||||
Reference in New Issue
Block a user