Skip to content

Commit

Permalink
* Fixing profile audio box not being able to select pattern match
Browse files Browse the repository at this point in the history
* Fixing #561 Subtitles all show as English in FastFlix subtitles screen (thanks to David James)
* Fixing #562 Audio conversion window defaults channel layout to stereo (thanks to David James)
* Fixing #563 No Thumbnails When Importing Video (thanks to Damundai)
* Fixing #564 Audio custom bitrate box shows units in kilobits/second but passes bits/second as the parameter (thanks to tcmbackwards)
  • Loading branch information
cdgriffith committed Jun 23, 2024
1 parent 07fc0c7 commit 27239cb
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 51 deletions.
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## Version 5.7.1

* Fixing profile audio box not being able to select pattern match
* Fixing #561 Subtitles all show as English in FastFlix subtitles screen (thanks to David James)
* Fixing #562 Audio conversion window defaults channel layout to stereo (thanks to David James)
* Fixing #563 No Thumbnails When Importing Video (thanks to Damundai)
* Fixing #564 Audio custom bitrate box shows units in kilobits/second but passes bits/second as the parameter (thanks to tcmbackwards)

## Version 5.7.0

* Adding new audio encoding panel
Expand Down
12 changes: 10 additions & 2 deletions fastflix/encoders/common/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,24 @@ def build_audio(audio_tracks, audio_file_index=0):
if not track.conversion_codec or track.conversion_codec == "none":
command_list.append(f"-c:{track.outdex} copy")
elif track.conversion_codec:
cl = track.downmix if "downmix" in track and track.downmix else track.raw_info.channel_layout
try:
cl = track.downmix if "downmix" in track and track.downmix else track.raw_info.channel_layout
except AssertionError:
cl = "stereo"
downmix = (
f"-ac:{track.outdex} {channel_list[cl]} -filter:{track.outdex} aformat=channel_layouts={cl}"
if track.downmix
else ""
)
bitrate = ""
if track.conversion_codec not in lossless:
conversion_bitrate = (
track.conversion_bitrate
if track.conversion_bitrate.lower().endswith(("k", "m", "g", "kb", "mb", "gb"))
else f"{track.conversion_bitrate}k"
)
channel_layout = f'-filter:{track.outdex} aformat=channel_layouts="{track.raw_info.channel_layout}"'
bitrate = f"-b:{track.outdex} {track.conversion_bitrate} {channel_layout}"
bitrate = f"-b:{track.outdex} {conversion_bitrate} {channel_layout}"
command_list.append(f"-c:{track.outdex} {track.conversion_codec} {bitrate} {downmix}")

if getattr(track, "dispositions", None):
Expand Down
7 changes: 6 additions & 1 deletion fastflix/encoders/common/encc_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ def build_audio(audio_tracks: list[AudioTrack], audio_streams):
bitrate = ""
if track.conversion_codec not in lossless:
if track.conversion_bitrate:
bitrate = f"--audio-bitrate {audio_id}?{track.conversion_bitrate} "
conversion_bitrate = (
track.conversion_bitrate
if track.conversion_bitrate.lower().endswith(("k", "m", "g", "kb", "mb", "gb"))
else f"{track.conversion_bitrate}k"
)
bitrate = f"--audio-bitrate {audio_id}?{conversion_bitrate} "
else:
bitrate = f"--audio-quality {audio_id}?{track.conversion_aq} "
command_list.append(
Expand Down
3 changes: 3 additions & 0 deletions fastflix/encoders/common/setting_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ def _add_modes(

return layout

def set_mode(self):
raise NotImplementedError("Child must implement this function")

@property
def ffmpeg_extras(self):
return ffmpeg_extra_command
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.0"
__version__ = "5.7.1"
__author__ = "Chris Griffith"
8 changes: 5 additions & 3 deletions fastflix/widgets/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1681,12 +1681,14 @@ def thread_logger(text):

@reusables.log_exception("fastflix", show_traceback=False)
def thumbnail_generated(self, status=0):
if status == 0 or not status or not self.thumb_file.exists():
self.widgets.preview.setText(t("Error Updating Thumbnail"))
return
if status == 2:
self.app.fastflix.opencl_support = False
self.generate_thumbnail()
return
if status == 0 or not status or not self.thumb_file.exists():
self.widgets.preview.setText(t("Error Updating Thumbnail"))
return

pixmap = QtGui.QPixmap(str(self.thumb_file))
pixmap = pixmap.scaled(420, 260, QtCore.Qt.KeepAspectRatio)
self.widgets.preview.setPixmap(pixmap)
Expand Down
8 changes: 5 additions & 3 deletions fastflix/widgets/panels/abstract_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ def __init__(self, app: FastFlixApp, parent, list_name, list_type, top_row_layou
self.inner_layout = None
self.list_type = list_type

layout = QtWidgets.QGridLayout()
layout = QtWidgets.QVBoxLayout()
if top_row_layout:
layout.addLayout(top_row_layout, 0, 0)
layout.addLayout(top_row_layout)
else:
layout.addWidget(QtWidgets.QLabel(t(list_name)))
header_text = QtWidgets.QLabel(t(list_name))
header_text.setFixedHeight(30)
layout.addWidget(header_text)

self.inner_widget = QtWidgets.QWidget()

Expand Down
10 changes: 1 addition & 9 deletions fastflix/widgets/panels/audio_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,13 @@ def init_move_buttons(self):
layout.addWidget(self.widgets.down_button)
return layout

def get_conversion_bitrates(self, channels=None):
if not channels:
channels = self.channels or 2
bitrates = [x for x in range(16 * channels, (256 * channels) + 1, 16 * channels)]
if channels > 1:
bitrates.append(640)
return [f"{x}k" for x in sorted(set(bitrates))]

def update_enable(self):
enabled = self.widgets.enable_check.isChecked()
audio_track = self.app.fastflix.current_video.audio_tracks[self.index]
audio_track.enabled = enabled
self.widgets.track_number.setText(f"{audio_track.index}:{audio_track.outdex}" if enabled else "❌")
self.parent.reorder(update=True)
self.parent.parent.subtitles.reorder()
# self.parent.parent.subtitles.reorder()

def page_update(self):
if not self.loading:
Expand Down
13 changes: 8 additions & 5 deletions fastflix/widgets/panels/subtitle_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ def __init__(self, app, parent, index, enabled=True, first=False):
self.outdex = None
self.first = first
self.last = False
self.setFixedHeight(60)
# self.setFixedHeight(180)
sub_track: SubtitleTrack = self.app.fastflix.current_video.subtitle_tracks[index]
long_name = (
f" {sub_track.long_name}" if sub_track.long_name else f" {t('Subtitle Type')}:{sub_track.subtitle_type}"
)

self.widgets = Box(
track_number=QtWidgets.QLabel(f"{sub_track.index}:{sub_track.outdex}" if enabled else "❌"),
title=QtWidgets.QLabel(f" {sub_track.long_name}"),
title=QtWidgets.QLabel(long_name),
up_button=QtWidgets.QPushButton(
QtGui.QIcon(get_icon("up-arrow", self.parent.app.fastflix.config.theme)), ""
),
Expand Down Expand Up @@ -135,7 +138,7 @@ def __init__(self, app, parent, index, enabled=True, first=False):

self.grid.addLayout(disposition_layout, 0, 4)
self.grid.addWidget(self.widgets.burn_in, 0, 5)
self.grid.addLayout(self.init_language(), 0, 6)
self.grid.addLayout(self.init_language(sub_track), 0, 6)

self.grid.addWidget(self.widgets.enable_check, 0, 8)

Expand Down Expand Up @@ -170,11 +173,11 @@ def extract(self):
self.widgets.extract.hide()
self.movie.start()

def init_language(self):
def init_language(self, sub_track: SubtitleTrack):
self.widgets.language.addItems(language_list)
self.widgets.language.setMaximumWidth(110)
try:
self.widgets.language.setCurrentIndex(language_list.index(Lang(self.subtitle_lang).name))
self.widgets.language.setCurrentIndex(language_list.index(Lang(sub_track.language).name))
except Exception:
self.widgets.language.setCurrentIndex(language_list.index("English"))
self.widgets.language.currentIndexChanged.connect(self.page_update)
Expand Down
24 changes: 22 additions & 2 deletions fastflix/widgets/windows/audio_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"quad(side)": 4,
"5.0": 5,
"5.1": 6,
"5.1(side)": 6,
"6.0": 6,
"6.0(front)": 6,
"hexagonal": 6,
Expand All @@ -52,6 +53,17 @@
"7.1(wide)": 8,
}

back_channel_list = {
1: "mono",
2: "stereo",
3: "2.1",
4: "3.1",
5: "5.0",
6: "5.1",
7: "6.1",
8: "7.1",
}


class AudioConversion(QtWidgets.QWidget):
def __init__(self, app: FastFlixApp, track_index, encoders, audio_track_update):
Expand Down Expand Up @@ -118,11 +130,19 @@ def __init__(self, app: FastFlixApp, track_index, encoders, audio_track_update):
quality_layout.addWidget(self.bitrate)
quality_layout.addWidget(QtWidgets.QLabel("kb/s"))

# Downmix
channel_layout = self.audio_track.raw_info.get("channel_layout")

self.downmix = QtWidgets.QComboBox()
self.downmix.addItems([t("None")] + list(channel_list.keys()))
self.downmix.setCurrentIndex(2)
try:
if channel_layout:
self.downmix.setCurrentText(channel_layout)
else:
guess = back_channel_list[self.audio_track.raw_info.get("channels")]
logger.warning(f"Channel layout not found for {self.audio_track.title}, guessing {guess}")
self.downmix.setCurrentText(guess)
except Exception:
self.downmix.setCurrentIndex(2)
if self.audio_track.downmix:
self.downmix.setCurrentText(self.audio_track.downmix)

Expand Down
69 changes: 44 additions & 25 deletions fastflix/widgets/windows/profile_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,35 +164,54 @@ def __init__(self, app, parent, main):
self.tracks = []
self.main = main

self.passthrough_checkbox = QtWidgets.QCheckBox(t("Passthrough All"))
self.disable_audio_checkbox = QtWidgets.QCheckBox(t("Don't Select Any Audio"))
self.audio_select_type = QtWidgets.QButtonGroup()

self.passthrough_name = t("Passthrough All")
self.disable_audio_name = t("Don't Select Any Audio")
self.patter_match_name = t("Pattern Match")

self.passthrough_checkbox = QtWidgets.QRadioButton(self.passthrough_name)
self.disable_audio_checkbox = QtWidgets.QRadioButton(self.disable_audio_name)
self.patter_match_checkbox = QtWidgets.QRadioButton(self.patter_match_name)

self.audio_select_type.addButton(self.passthrough_checkbox)
self.audio_select_type.addButton(self.disable_audio_checkbox)
self.audio_select_type.addButton(self.patter_match_checkbox)
self.audio_select_type.buttonClicked.connect(self.set_audio_mode)

self.add_button = QtWidgets.QPushButton(f' {t("Add Pattern Match")} ')
if self.app.fastflix.config.theme == "onyx":
self.add_button.setStyleSheet("border-radius: 10px;")

self.passthrough_checkbox.toggled.connect(self.passthrough_check)
self.disable_audio_checkbox.toggled.connect(self.disable_audio_check)
# self.passthrough_checkbox.toggled.connect(self.passthrough_check)
# self.disable_audio_checkbox.toggled.connect(self.disable_audio_check)

self.add_button.clicked.connect(self.add_track)

button_layout = QtWidgets.QVBoxLayout()
button_layout.addWidget(self.passthrough_checkbox)
button_layout.addWidget(self.disable_audio_checkbox)
button_layout.addWidget(self.patter_match_checkbox)

top_layout = QtWidgets.QHBoxLayout()
top_layout.addLayout(button_layout)
top_layout.addWidget(self.add_button)

layout = self.layout()
# self.scroll_area = super().scroll_area
layout.removeWidget(self.scroll_area)
layout.addLayout(top_layout)

layout.addWidget(self.passthrough_checkbox, 0, 0)
layout.addWidget(self.disable_audio_checkbox, 0, 1)
layout.addWidget(self.add_button, 0, 2, alignment=QtCore.Qt.AlignRight)

layout.addWidget(self.scroll_area, 1, 0, 1, 3)
layout.addWidget(self.scroll_area)

self.hardware_warning = QtWidgets.QLabel(t("Rigaya's encoders will only match one encoding per track"))
self.hardware_warning.hide()

layout.addWidget(self.hardware_warning, 2, 0)
layout.addWidget(self.hardware_warning)
self.passthrough_checkbox.setChecked(True)
self.disable_audio_checkbox.setChecked(False)
# self.passthrough_checkbox.setChecked(True)
self.scroll_area.setDisabled(True)
self.add_button.setDisabled(True)

super()._new_source(self.tracks)

def update_settings(self):
Expand All @@ -212,23 +231,23 @@ def remove_track(self, index):
track.index = i
self.reorder(height=126)

def passthrough_check(self):
if self.passthrough_checkbox.isChecked():
if self.disable_audio_checkbox.isChecked():
self.disable_audio_checkbox.setChecked(False)
def set_audio_mode(self, button):
if button.text() == self.passthrough_name:
# self.passthrough_checkbox.setChecked(True)
# self.disable_audio_checkbox.setChecked(False)
# self.patter_match_checkbox.setChecked(False)
self.scroll_area.setDisabled(True)
self.add_button.setDisabled(True)
else:
self.scroll_area.setEnabled(True)
self.add_button.setEnabled(True)

def disable_audio_check(self):
if self.disable_audio_checkbox.isChecked():
if self.passthrough_checkbox.isChecked():
self.passthrough_checkbox.setChecked(False)
elif button.text() == self.disable_audio_name:
# self.passthrough_checkbox.setChecked(False)
# self.disable_audio_checkbox.setChecked(True)
# self.patter_match_checkbox.setChecked(False)
self.scroll_area.setDisabled(True)
self.add_button.setDisabled(True)
else:
elif button.text() == self.patter_match_name:
# self.passthrough_checkbox.setChecked(False)
# self.disable_audio_checkbox.setChecked(False)
# self.patter_match_checkbox.setChecked(True)
self.scroll_area.setEnabled(True)
self.add_button.setEnabled(True)

Expand Down

0 comments on commit 27239cb

Please sign in to comment.