From 20ec4f5759f9ef06f9cd444fe0747bdd609d5329 Mon Sep 17 00:00:00 2001 From: Chris Griffith Date: Mon, 5 Aug 2024 20:22:41 -0500 Subject: [PATCH] * Fixing #586 audio channels being set incorrectly (thanks to Hankuu) * Fixing #588 audio and subtitle dispositions were not set from source (thanks to GeZorTenPlotZ) --- CHANGES | 5 ++++ fastflix/data/languages.yaml | 15 ++++++++++ fastflix/encoders/common/audio.py | 14 ++++++---- fastflix/version.py | 2 +- fastflix/widgets/panels/audio_panel.py | 8 ++++++ fastflix/widgets/panels/subtitle_panel.py | 9 ++++++ fastflix/widgets/windows/disposition.py | 34 +++++++++++++---------- 7 files changed, 66 insertions(+), 21 deletions(-) diff --git a/CHANGES b/CHANGES index 77195c9e..20cdcc0e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,10 @@ # Changelog +## Version 5.7.5 + +* Fixing #586 audio channels being set incorrectly (thanks to Hankuu) +* Fixing #588 audio and subtitle dispositions were not set from source (thanks to GeZorTenPlotZ) + ## Version 5.7.4 * Fixing #579 Missing Infos and no Mouse-Over info in Subs-Panel since 5.7 (thanks to GeZorTenPlotZ) diff --git a/fastflix/data/languages.yaml b/fastflix/data/languages.yaml index dd138523..5c87270d 100644 --- a/fastflix/data/languages.yaml +++ b/fastflix/data/languages.yaml @@ -10730,3 +10730,18 @@ Subtitle Type: ukr: Тип субтитрів kor: 자막 유형 ron: Tip subtitrare +Pattern Match: + eng: Pattern Match + deu: Mustervergleich + fra: Correspondance des motifs + ita: Corrispondenza dei modelli + spa: Coincidencia de patrones + jpn: パターン・マッチ + rus: Соответствие шаблону + por: Correspondência de padrões + swe: Mönstermatchning + pol: Dopasowanie wzorca + chs: 模式匹配 + ukr: Збіг за зразком + kor: 패턴 일치 + ron: Potrivire model diff --git a/fastflix/encoders/common/audio.py b/fastflix/encoders/common/audio.py index 9efc374c..e78b52d6 100644 --- a/fastflix/encoders/common/audio.py +++ b/fastflix/encoders/common/audio.py @@ -1,5 +1,8 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import logging + +logger = logging.getLogger("fastflix") channel_list = { "mono": 1, @@ -67,13 +70,12 @@ def build_audio(audio_tracks, audio_file_index=0): cl = track.downmix if track.downmix and track.downmix != "No Downmix" else track.raw_info.channel_layout except (AssertionError, KeyError): cl = "stereo" + logger.warning("Could not determine channel layout, defaulting to stereo, please manually specify") downmix = ( - f"-ac:{track.outdex} {channel_list[cl]} -filter:{track.outdex} aformat=channel_layouts={cl}" - if track.downmix and track.downmix != "No Downmix" - else "" + f"-ac:{track.outdex} {channel_list[cl]}" if track.downmix and track.downmix != "No Downmix" else "" ) - channel_layout = f'-filter:{track.outdex} aformat=channel_layouts="{channel_list[cl]}"' + channel_layout = f'-filter:{track.outdex} "aformat=channel_layouts={cl}"' bitrate = "" if track.conversion_codec not in lossless: @@ -84,13 +86,13 @@ def build_audio(audio_tracks, audio_file_index=0): else f"{track.conversion_bitrate}k" ) - bitrate = f"-b:{track.outdex} {conversion_bitrate} {channel_layout}" + bitrate = f"-b:{track.outdex} {conversion_bitrate}" else: bitrate = audio_quality_converter( track.conversion_aq, track.conversion_codec, track.raw_info.get("channels"), track.outdex ) - command_list.append(f"-c:{track.outdex} {track.conversion_codec} {bitrate} {downmix}") + command_list.append(f"-c:{track.outdex} {track.conversion_codec} {bitrate} {downmix} {channel_layout}") if getattr(track, "dispositions", None): added = "" diff --git a/fastflix/version.py b/fastflix/version.py index d61958af..e6cf9cb1 100644 --- a/fastflix/version.py +++ b/fastflix/version.py @@ -1,4 +1,4 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -__version__ = "5.7.4" +__version__ = "5.7.5" __author__ = "Chris Griffith" diff --git a/fastflix/widgets/panels/audio_panel.py b/fastflix/widgets/panels/audio_panel.py index ee08e360..b47bf1ff 100644 --- a/fastflix/widgets/panels/audio_panel.py +++ b/fastflix/widgets/panels/audio_panel.py @@ -202,6 +202,7 @@ def page_update(self): self.app.fastflix.current_video.audio_tracks[self.index].language = self.language if not self.loading: self.check_conversion_button() + self.check_dis_button() return self.parent.main.page_update(build_thumbnail=False) @property @@ -286,6 +287,13 @@ def check_conversion_button(self): self.widgets.conversion.setStyleSheet("") self.widgets.conversion.setText(t("Conversion")) + def check_dis_button(self): + audio_track: AudioTrack = self.app.fastflix.current_video.audio_tracks[self.index] + if any(audio_track.dispositions.values()): + self.widgets.disposition.setStyleSheet("border-color: #0055ff") + else: + self.widgets.disposition.setStyleSheet("") + class AudioList(FlixList): def __init__(self, parent, app: FastFlixApp): diff --git a/fastflix/widgets/panels/subtitle_panel.py b/fastflix/widgets/panels/subtitle_panel.py index e0e0f8c8..cdd14627 100644 --- a/fastflix/widgets/panels/subtitle_panel.py +++ b/fastflix/widgets/panels/subtitle_panel.py @@ -143,6 +143,7 @@ def __init__(self, app, parent, index, enabled=True, first=False): self.grid.addWidget(self.widgets.enable_check, 0, 8) self.setLayout(self.grid) + self.check_dis_button() self.loading = False self.updating_burn = False self.extract_completed_signal.connect(self.extraction_complete) @@ -242,8 +243,16 @@ def update_burn_in(self): def page_update(self): if not self.loading: + self.check_dis_button() return self.parent.main.page_update(build_thumbnail=False) + def check_dis_button(self): + track: SubtitleTrack = self.app.fastflix.current_video.subtitle_tracks[self.index] + if any(track.dispositions.values()): + self.widgets.disposition.setStyleSheet("border-color: #0055ff") + else: + self.widgets.disposition.setStyleSheet("") + class SubtitleList(FlixList): def __init__(self, parent, app: FastFlixApp): diff --git a/fastflix/widgets/windows/disposition.py b/fastflix/widgets/windows/disposition.py index 9ad0d9e5..fe156c41 100644 --- a/fastflix/widgets/windows/disposition.py +++ b/fastflix/widgets/windows/disposition.py @@ -51,6 +51,10 @@ def __init__(self, app: FastFlixApp, parent, track_name, track_index, audio=True self.default = QtWidgets.QCheckBox(t("Default")) + track = self.get_track() + self.forced.setChecked(track.dispositions.get("forced", False)) + self.default.setChecked(track.dispositions.get("default", False)) + layout = QtWidgets.QVBoxLayout() layout.addWidget(QtWidgets.QLabel(track_name)) layout.addWidget(self.default) @@ -71,16 +75,16 @@ def __init__(self, app: FastFlixApp, parent, track_name, track_index, audio=True group.addButton(none_extra) layout.addWidget(none_extra) - if audio: - for dis in audio_disposition_options: - self.widgets[dis] = QtWidgets.QRadioButton(t(dis)) - group.addButton(self.widgets[dis]) - layout.addWidget(self.widgets[dis]) - else: - for dis in subtitle_disposition_options: - self.widgets[dis] = QtWidgets.QRadioButton(t(dis)) - group.addButton(self.widgets[dis]) - layout.addWidget(self.widgets[dis]) + for dis in audio_disposition_options if audio else subtitle_disposition_options: + self.widgets[dis] = QtWidgets.QRadioButton(t(dis)) + group.addButton(self.widgets[dis]) + layout.addWidget(self.widgets[dis]) + + for track_dis, is_set in track.dispositions.items(): + if is_set and track_dis in self.widgets.keys(): + self.widgets[track_dis].setChecked(True) + + self.parent.page_update() self.set_button = QtWidgets.QPushButton(t("Set")) self.set_button.clicked.connect(self.set_dispositions) @@ -88,11 +92,13 @@ def __init__(self, app: FastFlixApp, parent, track_name, track_index, audio=True self.setLayout(layout) - def set_dispositions(self): + def get_track(self): if self.audio: - track = self.app.fastflix.current_video.audio_tracks[self.track_index] - else: - track = self.app.fastflix.current_video.subtitle_tracks[self.track_index] + return self.app.fastflix.current_video.audio_tracks[self.track_index] + return self.app.fastflix.current_video.subtitle_tracks[self.track_index] + + def set_dispositions(self): + track = self.get_track() track.dispositions["forced"] = self.forced.isChecked() track.dispositions["default"] = self.default.isChecked()