feat(tracks): Add duration fix handling for video and hybrid tracks

This commit is contained in:
Andy
2025-07-30 21:39:34 +00:00
parent fdff3a1c56
commit 4de9251f95
3 changed files with 31 additions and 15 deletions

View File

@@ -959,6 +959,9 @@ class dl:
# Create track pair for this resolution # Create track pair for this resolution
resolution_tracks = [hdr10_track, matching_dv] resolution_tracks = [hdr10_track, matching_dv]
for track in resolution_tracks:
track.needs_duration_fix = True
# Run the hybrid processing for this resolution # Run the hybrid processing for this resolution
Hybrid(resolution_tracks, self.service) Hybrid(resolution_tracks, self.service)
@@ -982,6 +985,7 @@ class dl:
hybrid_track = deepcopy(hdr10_track) hybrid_track = deepcopy(hdr10_track)
hybrid_track.path = hybrid_output_path hybrid_track.path = hybrid_output_path
hybrid_track.range = Video.Range.DV # It's now a DV track hybrid_track.range = Video.Range.DV # It's now a DV track
hybrid_track.needs_duration_fix = True
task_tracks.videos = [hybrid_track] task_tracks.videos = [hybrid_track]
multiplex_tasks.append((task_id, task_tracks)) multiplex_tasks.append((task_id, task_tracks))

View File

@@ -331,8 +331,9 @@ class Tracks:
if not vt.path or not vt.path.exists(): if not vt.path or not vt.path.exists():
raise ValueError("Video Track must be downloaded before muxing...") raise ValueError("Video Track must be downloaded before muxing...")
events.emit(events.Types.TRACK_MULTIPLEX, track=vt) events.emit(events.Types.TRACK_MULTIPLEX, track=vt)
cl.extend(
[ # Prepare base arguments
video_args = [
"--language", "--language",
f"0:{vt.language}", f"0:{vt.language}",
"--default-track", "--default-track",
@@ -341,12 +342,21 @@ class Tracks:
f"0:{vt.is_original_lang}", f"0:{vt.is_original_lang}",
"--compression", "--compression",
"0:none", # disable extra compression "0:none", # disable extra compression
"(", ]
str(vt.path),
")", # Add FPS fix if needed (typically for hybrid mode to prevent sync issues)
if hasattr(vt, "needs_duration_fix") and vt.needs_duration_fix and vt.fps:
video_args.extend(
[
"--default-duration",
f"0:{vt.fps}fps" if isinstance(vt.fps, str) else f"0:{vt.fps:.3f}fps",
"--fix-bitstream-timing-information",
"0:1",
] ]
) )
cl.extend(video_args + ["(", str(vt.path), ")"])
for i, at in enumerate(self.audio): for i, at in enumerate(self.audio):
if not at.path or not at.path.exists(): if not at.path or not at.path.exists():
raise ValueError("Audio Track must be downloaded before muxing...") raise ValueError("Audio Track must be downloaded before muxing...")

View File

@@ -237,6 +237,8 @@ class Video(Track):
except Exception as e: except Exception as e:
raise ValueError("Expected fps to be a number, float, or a string as numerator/denominator form, " + str(e)) raise ValueError("Expected fps to be a number, float, or a string as numerator/denominator form, " + str(e))
self.needs_duration_fix = False
def __str__(self) -> str: def __str__(self) -> str:
return " | ".join( return " | ".join(
filter( filter(