Skip to content

Commit

Permalink
* Fixing #586 audio channels being set incorrectly (thanks to Hankuu)
Browse files Browse the repository at this point in the history
* Fixing #588 audio and subtitle dispositions were not set from source (thanks to GeZorTenPlotZ)
  • Loading branch information
cdgriffith committed Aug 6, 2024
1 parent 72dcbe1 commit 20ec4f5
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
15 changes: 15 additions & 0 deletions fastflix/data/languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 8 additions & 6 deletions fastflix/encoders/common/audio.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging

logger = logging.getLogger("fastflix")

channel_list = {
"mono": 1,
Expand Down Expand Up @@ -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:
Expand All @@ -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 = ""
Expand Down
2 changes: 1 addition & 1 deletion fastflix/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__version__ = "5.7.4"
__version__ = "5.7.5"
__author__ = "Chris Griffith"
8 changes: 8 additions & 0 deletions fastflix/widgets/panels/audio_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
9 changes: 9 additions & 0 deletions fastflix/widgets/panels/subtitle_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
34 changes: 20 additions & 14 deletions fastflix/widgets/windows/disposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -71,28 +75,30 @@ 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)
layout.addWidget(self.set_button)

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()
Expand Down

0 comments on commit 20ec4f5

Please sign in to comment.