Skip to content

Commit bd4382f

Browse files
FIX: Ensure undesired streams are removed from all pipelines in ./main.py
1 parent 4cf6e77 commit bd4382f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • Default Audio Track Switcher

Default Audio Track Switcher/main.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,8 @@ def should_skip_processing_for_correct_defaults(video_path, audio_streams, subti
10781078

10791079
current_audio_language = detect_stream_language_for_validation(default_audio_stream, "audio") # Detect canonical language for current default audio stream.
10801080
current_subtitle_language = detect_stream_language_for_validation(default_subtitle_stream, "subtitle") # Detect canonical language for current default subtitle stream.
1081-
desired_subtitle_positions = [s.get("sub_pos") for s in subtitle_streams if s.get("classification") == "desired"] # Compute desired subtitle positions for strict default verification.
1081+
filtered_subtitle_streams = filter_undesired_streams(subtitle_streams) # Remove descriptive/forced subtitles before position extraction.
1082+
desired_subtitle_positions = [s.get("sub_pos") for s in filtered_subtitle_streams if s.get("classification") == "desired"] # Compute desired subtitle positions from filtered streams.
10821083
subtitle_priorities = resolve_priority_list("subtitle") # Resolve configured subtitle priorities for strict default verification.
10831084
expected_subtitle_pos = select_best_subtitle_stream(subtitle_streams, desired_subtitle_positions, subtitle_priorities, "sub_pos") # Resolve expected default subtitle position using strict intra-language priority.
10841085
current_default_subtitle_pos = default_subtitle_stream.get("sub_pos") # Resolve current default subtitle position for equality verification.
@@ -1104,8 +1105,10 @@ def apply_prune_and_set_defaults(video_path, audio_streams, subtitle_streams):
11041105
ext = ext.lower() # Normalize extension to lowercase
11051106
temp_file = root + ".tmp" + ext # Build temporary output path
11061107

1107-
kept_audio_positions = [a.get("audio_pos") for a in audio_streams if a.get("classification") == "desired"] # Compute desired audio positions
1108-
kept_sub_positions = [s.get("sub_pos") for s in subtitle_streams if s.get("classification") == "desired"] # Compute desired subtitle positions
1108+
filtered_audio_streams = filter_undesired_streams(audio_streams) # Remove descriptive/forced audio before position extraction.
1109+
kept_audio_positions = [a.get("audio_pos") for a in filtered_audio_streams if a.get("classification") == "desired"] # Compute desired audio positions from filtered streams.
1110+
filtered_subtitle_streams = filter_undesired_streams(subtitle_streams) # Remove descriptive/forced subtitles before position extraction.
1111+
kept_sub_positions = [s.get("sub_pos") for s in filtered_subtitle_streams if s.get("classification") == "desired"] # Compute desired subtitle positions from filtered streams.
11091112

11101113
if not kept_audio_positions: # If no desired audio streams were found then abort per strict rules
11111114
print(f"{BackgroundColors.YELLOW}No desired audio tracks found for: {BackgroundColors.CYAN}{video_path}{Style.RESET_ALL}") # Notify user

0 commit comments

Comments
 (0)