Skip to content

Commit

Permalink
Version 5.5.7 (#518)
Browse files Browse the repository at this point in the history
* Fixing #503 missing CRF mode for SVT-AV1 (thanks to ignace72)
* Fixing #506 excessive amounts of RAM used and not cleared - partially mitigated (thanks to 19Battlestar65)
* Fixing #509 Portuguese translations (thanks to Felipe Augusto Arantes de Souza)
* Fixing #513 Profile configuration issues, including with load directory (thanks to Nikita S.)
* Fixing #516 Performance improvements due to constant stream reads (thanks to William Barath)

---------

Co-authored-by: Felipe Augusto Arantes de Souza <felipmoreira8@gmail.com>
  • Loading branch information
cdgriffith and mindwired committed Aug 26, 2023
1 parent 9a6a50a commit 80cca41
Show file tree
Hide file tree
Showing 25 changed files with 693 additions and 541 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
python-version: "3.11"

- run: pip install black==23.1.0
- run: pip install black==23.7.0
- run: python -m black --check .

test:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -19,7 +19,7 @@ repos:
- id: detect-private-key
- id: end-of-file-fixer
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.7.0
hooks:
- id: black
# - repo: https://github.com/pre-commit/mirrors-mypy
Expand Down
8 changes: 8 additions & 0 deletions CHANGES
@@ -1,5 +1,13 @@
# Changelog

## Version 5.5.7

* Fixing #503 missing CRF mode for SVT-AV1 (thanks to ignace72)
* Fixing #506 excessive amounts of RAM used and not cleared - partially mitigated (thanks to 19Battlestar65)
* Fixing #509 Portuguese translations (thanks to Felipe Augusto Arantes de Souza)
* Fixing #513 Profile configuration issues, including with load directory (thanks to Nikita S.)
* Fixing #516 Performance improvements due to constant stream reads (thanks to William Barath)

## Version 5.5.6

* Fixing #485 Cannot Restore Queue Containing HDR10+ Entries (thanks to Maddie Davis)
Expand Down
4 changes: 4 additions & 0 deletions fastflix/application.py
Expand Up @@ -240,6 +240,10 @@ def app_setup(


def start_app(worker_queue, status_queue, log_queue, queue_list, queue_lock, portable_mode=False, enable_scaling=True):
# import tracemalloc
#
# tracemalloc.start()

app = app_setup(
enable_scaling=enable_scaling,
portable_mode=portable_mode,
Expand Down
2 changes: 2 additions & 0 deletions fastflix/command_runner.py
Expand Up @@ -4,6 +4,7 @@
import logging
import secrets
import shlex
import time
from pathlib import Path
from subprocess import PIPE
from threading import Thread
Expand Down Expand Up @@ -113,6 +114,7 @@ def read_output(self):
self.error_output_file, "r", encoding="utf-8", errors="ignore"
) as err_file:
while True:
time.sleep(0.01)
if not self.is_alive():
excess = out_file.read()
logger.info(excess)
Expand Down
988 changes: 513 additions & 475 deletions fastflix/data/languages.yaml

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions fastflix/encoders/common/setting_panel.py
Expand Up @@ -11,6 +11,7 @@
from fastflix.models.fastflix_app import FastFlixApp
from fastflix.widgets.background_tasks import ExtractHDR10
from fastflix.resources import group_box_style, get_icon
from fastflix.shared import clear_list

logger = logging.getLogger("fastflix")

Expand Down Expand Up @@ -74,6 +75,14 @@ def __init__(self, parent, main, app: FastFlixApp, *args, **kwargs):
self.opts = Box()
self.only_int = QtGui.QIntValidator()

def close(self) -> bool:
for widget, item in self.widgets.items():
self.widgets[widget] = None
del self.widgets
del self.labels
del self.opts
return super().close()

def paintEvent(self, event):
o = QtWidgets.QStyleOption()
o.initFrom(self)
Expand Down
4 changes: 2 additions & 2 deletions fastflix/encoders/svt_av1/command_builder.py
Expand Up @@ -97,8 +97,8 @@ def convert_me(two_numbers, conversion_rate=50_000) -> str:
command_2 = f"{beginning} -b:v {settings.bitrate} -pass 2 {settings.extra} {ending}"

elif settings.qp is not None:
command_1 = f"{beginning} -qp {settings.qp} -pass 1 {settings.extra if settings.extra_both_passes else ''} -an {output_fps} -f matroska {null}"
command_2 = f"{beginning} -qp {settings.qp} -pass 2 {settings.extra} {ending}"
command_1 = f"{beginning} -{settings.qp_mode} {settings.qp} -pass 1 {settings.extra if settings.extra_both_passes else ''} -an {output_fps} -f matroska {null}"
command_2 = f"{beginning} -{settings.qp_mode} {settings.qp} -pass 2 {settings.extra} {ending}"
else:
return []
return [
Expand Down
2 changes: 1 addition & 1 deletion fastflix/encoders/svt_av1/settings_panel.py
Expand Up @@ -76,7 +76,7 @@ def __init__(self, parent, main, app: FastFlixApp):
grid.addLayout(self.init_pix_fmt(), 1, 0, 1, 2)
grid.addLayout(self.init_tile_rows(), 2, 0, 1, 2)
grid.addLayout(self.init_tile_columns(), 3, 0, 1, 2)
grid.addLayout(self.init_qp_or_crf(), 5, 0, 1, 2)
grid.addLayout(self.init_qp_or_crf(), 6, 0, 1, 2)
grid.addLayout(self.init_sc_detection(), 4, 0, 1, 2)
grid.addLayout(self.init_max_mux(), 5, 0, 1, 2)
grid.addLayout(self.init_modes(), 0, 2, 5, 4)
Expand Down
7 changes: 6 additions & 1 deletion fastflix/ff_queue.py
Expand Up @@ -5,6 +5,7 @@
import logging
import shutil
import uuid
import gc

from box import Box, BoxError
from ruamel.yaml import YAMLError
Expand Down Expand Up @@ -65,6 +66,7 @@ def get_queue(queue_file: Path) -> list[Video]:
vs.video_encoder_settings = ves # No idea why this has to be called after, otherwise reset to x265
del video["video_settings"]
queue.append(Video(**video, video_settings=vs, status=status))
del loaded
return queue


Expand Down Expand Up @@ -122,8 +124,11 @@ def update_conversion_command(vid, old_path: str, new_path: str):

items.append(video)
try:
Box(queue=items).to_yaml(filename=queue_file)
tmp = Box(queue=items)
tmp.to_yaml(filename=queue_file)
del tmp
except Exception as err:
logger.warning(items)
logger.exception(f"Could not save queue! {err.__class__.__name__}: {err}")
raise err from None
gc.collect(2)
10 changes: 8 additions & 2 deletions fastflix/models/video.py
Expand Up @@ -186,12 +186,18 @@ class Video(BaseModel):

@property
def width(self):
w, _ = determine_rotation(self.streams, self.video_settings.selected_track)
track = 0
if hasattr(self, "video_settings"):
track = self.video_settings.selected_track
w, _ = determine_rotation(self.streams, track)
return w

@property
def height(self):
_, h = determine_rotation(self.streams, self.video_settings.selected_track)
track = 0
if hasattr(self, "video_settings"):
track = self.video_settings.selected_track
_, h = determine_rotation(self.streams, track)
return h

@property
Expand Down
7 changes: 7 additions & 0 deletions fastflix/shared.py
Expand Up @@ -331,3 +331,10 @@ def get_config(portable_mode=False):
if Path("fastflix.yaml").exists() or portable_mode:
return Path("fastflix.yaml")
return Path(user_data_dir("FastFlix", appauthor=False, roaming=True)) / "fastflix.yaml"


def clear_list(the_list: list, close=False):
for i in range(len(the_list) - 1, -1, -1):
if close:
the_list[i].close()
del the_list[i]
2 changes: 1 addition & 1 deletion fastflix/version.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__version__ = "5.5.6"
__version__ = "5.5.7"
__author__ = "Chris Griffith"
8 changes: 4 additions & 4 deletions fastflix/widgets/about.py
Expand Up @@ -44,11 +44,11 @@ def __init__(self, app):
layout.addWidget(support_label)

bundle_label = QtWidgets.QLabel(
f"Conversion suites: {link('https://www.ffmpeg.org/download.html', 'FFmpeg', app.fastflix.config.theme)} ({t('Various')}), "
f"{t('Conversion suites')}: {link('https://www.ffmpeg.org/download.html', 'FFmpeg', app.fastflix.config.theme)} ({t('Various')}), "
f"{link('https://github.com/rigaya/NVEnc', 'NVEncC', app.fastflix.config.theme)} (MIT) "
f"{link('https://github.com/rigaya/QSVEnc', 'QSVEnc', app.fastflix.config.theme)} (MIT) "
f"{link('https://github.com/rigaya/VCEEnc', 'VCEEnc', app.fastflix.config.theme)} (MIT)<br><br>"
f"Encoders: <br> {link('https://github.com/rigaya/NVEnc', 'NVEncC', app.fastflix.config.theme)} (MIT), "
f"{t('Encoders')}: <br> {link('https://github.com/rigaya/NVEnc', 'NVEncC', app.fastflix.config.theme)} (MIT), "
f"{link('https://github.com/rigaya/VCEEnc', 'VCEEnc', app.fastflix.config.theme)} (MIT), "
f"{link('https://github.com/rigaya/QSVEnc', 'QSVEnc', app.fastflix.config.theme)} (MIT), "
f"SVT AV1 (MIT), rav1e (MIT), aom (MIT), x265 (GPL), x264 (GPL), libvpx (BSD)"
Expand All @@ -58,7 +58,7 @@ def __init__(self, app):
layout.addWidget(bundle_label)

supporting_libraries_label = QtWidgets.QLabel(
"Supporting libraries<br>"
f"{t('Supporting libraries')}<br>"
f"{link('https://www.python.org/', t('Python'), app.fastflix.config.theme)}{reusables.version_string} (PSF LICENSE), "
f"{link('https://github.com/cdgriffith/Box', t('python-box'), app.fastflix.config.theme)} {box_version} (MIT), "
f"{link('https://github.com/cdgriffith/Reusables', t('Reusables'), app.fastflix.config.theme)} {reusables.__version__} (MIT)<br>"
Expand All @@ -72,7 +72,7 @@ def __init__(self, app):

if pyinstaller:
pyinstaller_label = QtWidgets.QLabel(
f"Packaged with: {link('https://www.pyinstaller.org/index.html', 'PyInstaller', app.fastflix.config.theme)}"
f"{t('Packaged with')}: {link('https://www.pyinstaller.org/index.html', 'PyInstaller', app.fastflix.config.theme)}"
)
pyinstaller_label.setAlignment(QtCore.Qt.AlignCenter)
pyinstaller_label.setOpenExternalLinks(True)
Expand Down
35 changes: 22 additions & 13 deletions fastflix/widgets/container.py
Expand Up @@ -18,10 +18,11 @@
from fastflix.models.fastflix_app import FastFlixApp
from fastflix.program_downloads import latest_ffmpeg
from fastflix.resources import main_icon, get_icon, changes_file, local_changes_file, local_package_changes_file
from fastflix.shared import clean_logs, error_message, latest_fastflix, message
from fastflix.shared import clean_logs, error_message, latest_fastflix, message, yes_no_message
from fastflix.widgets.about import About
from fastflix.widgets.changes import Changes
from fastflix.widgets.logs import Logs

# from fastflix.widgets.logs import Logs
from fastflix.widgets.main import Main
from fastflix.widgets.windows.profile_window import ProfileWindow
from fastflix.widgets.progress_bar import ProgressBar, Task
Expand Down Expand Up @@ -62,7 +63,7 @@ def __init__(self, app: FastFlixApp, **kwargs):

if self.app.fastflix.config.stay_on_top:
self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
self.logs = Logs()
# self.logs = Logs()
self.changes = None
self.about = None
self.profile_details = None
Expand Down Expand Up @@ -224,8 +225,8 @@ def init_menu(self):
log_dir_action = QAction(self.si(QtWidgets.QStyle.SP_DialogOpenButton), t("Open Log Directory"), self)
log_dir_action.triggered.connect(self.show_log_dir)

log_action = QAction(self.si(QtWidgets.QStyle.SP_FileDialogDetailedView), t("View GUI Debug Logs"), self)
log_action.triggered.connect(self.show_logs)
# log_action = QAction(self.si(QtWidgets.QStyle.SP_FileDialogDetailedView), t("View GUI Debug Logs"), self)
# log_action.triggered.connect(self.show_logs)

report_action = QAction(self.si(QtWidgets.QStyle.SP_DialogHelpButton), t("Report Issue"), self)
report_action.triggered.connect(self.open_issues)
Expand All @@ -249,7 +250,7 @@ def init_menu(self):
help_menu.addAction(changes_action)
help_menu.addAction(report_action)
help_menu.addAction(log_dir_action)
help_menu.addAction(log_action)
# help_menu.addAction(log_action)
help_menu.addAction(clean_logs_action)
help_menu.addSeparator()
help_menu.addAction(version_action)
Expand Down Expand Up @@ -277,11 +278,11 @@ def new_profile(self):
if not self.app.fastflix.current_video:
error_message(t("Please load in a video to configure a new profile"))
else:
self.main.page_update(build_thumbnail=False)
if self.profile_window:
self.profile_window.show()
else:
self.profile_window = ProfileWindow(self.app, self.main, self)
self.profile_window.show()
self.profile_window.close()
self.profile_window = ProfileWindow(self.app, self.main, self)
self.profile_window.show()

def show_profile(self):
self.profile_details = ProfileDetails(
Expand All @@ -304,8 +305,8 @@ def delete_profile(self):
self.main.widgets.profile_box.setCurrentText("Standard Profile")
self.main.widgets.convert_to.setCurrentIndex(0)

def show_logs(self):
self.logs.show()
# def show_logs(self):
# self.logs.show()

def show_changes(self):
if not self.changes:
Expand Down Expand Up @@ -360,6 +361,14 @@ def set_stay_top(self):
self.app.fastflix.config.save()

def open_many(self):
if self.app.fastflix.current_video:
discard = yes_no_message(
f'{t("There is already a video being processed")}<br>' f'{t("Are you sure you want to discard it?")}',
title="Discard current video",
)
if not discard:
return
self.main.clear_current_video()
self.mfw = MultipleFilesWindow(app=self.app, main=self.main)
self.mfw.show()

Expand Down Expand Up @@ -425,7 +434,7 @@ def __init__(self, profile_name, profile):
if k.lower().startswith("audio") or k.lower() == "profile_version":
continue
if k not in setting_types.keys():
item_1 = QtWidgets.QLabel(" ".join(str(k).split("_")).title())
item_1 = QtWidgets.QLabel(t(" ".join(str(k).split("_")).title()))
item_2 = QtWidgets.QLabel(str(v))
item_2.setMaximumWidth(150)
inner_layout = QtWidgets.QHBoxLayout()
Expand Down
39 changes: 21 additions & 18 deletions fastflix/widgets/main.py
Expand Up @@ -869,23 +869,24 @@ def update_resolution(self):
elif self.widgets.resolution_drop_down.currentIndex() in {1, 2, 3, 4}:
self.widgets.resolution_custom.setDisabled(False)
self.widgets.resolution_custom.setPlaceholderText(self.widgets.resolution_drop_down.currentText())
match resolutions[self.widgets.resolution_drop_down.currentText()]["method"]:
case "long edge":
self.widgets.resolution_custom.setText(
str(self.app.fastflix.current_video.width)
if self.app.fastflix.current_video.width > self.app.fastflix.current_video.height
else str(self.app.fastflix.current_video.height)
)
case "width":
self.widgets.resolution_custom.setText(str(self.app.fastflix.current_video.width))
case "height":
self.widgets.resolution_custom.setText(str(self.app.fastflix.current_video.height))
case "custom":
self.widgets.resolution_custom.setText(
f"{self.app.fastflix.current_video.width}:{self.app.fastflix.current_video.height}"
)
case _:
self.widgets.resolution_custom.setText("")
if self.app.fastflix.current_video:
match resolutions[self.widgets.resolution_drop_down.currentText()]["method"]:
case "long edge":
self.widgets.resolution_custom.setText(
str(self.app.fastflix.current_video.width)
if self.app.fastflix.current_video.width > self.app.fastflix.current_video.height
else str(self.app.fastflix.current_video.height)
)
case "width":
self.widgets.resolution_custom.setText(str(self.app.fastflix.current_video.width))
case "height":
self.widgets.resolution_custom.setText(str(self.app.fastflix.current_video.height))
case "custom":
self.widgets.resolution_custom.setText(
f"{self.app.fastflix.current_video.width}:{self.app.fastflix.current_video.height}"
)
case _:
self.widgets.resolution_custom.setText("")
else:
self.widgets.resolution_custom.setDisabled(True)
self.widgets.resolution_custom.setText("")
Expand Down Expand Up @@ -1676,7 +1677,6 @@ def resolution_custom(self):
def get_all_settings(self):
if not self.initialized:
return
stream_info = self.app.fastflix.current_video.streams.video[self.video_track]

end_time = self.end_time
if self.end_time == float(self.app.fastflix.current_video.format.get("duration", 0)):
Expand All @@ -1685,6 +1685,8 @@ def get_all_settings(self):
end_time = 0

v_flip, h_flip = self.get_flips()

del self.app.fastflix.current_video.video_settings
self.app.fastflix.current_video.video_settings = VideoSettings(
crop=self.build_crop(),
resolution_method=self.resolution_method(),
Expand Down Expand Up @@ -2103,6 +2105,7 @@ def __del__(self):
def run(self):
while True:
# Message looks like (command, video_uuid, command_uuid)
# time.sleep(0.01)
status = self.status_queue.get()
self.app.processEvents()
if status[0] == "exit":
Expand Down
9 changes: 7 additions & 2 deletions fastflix/widgets/panels/abstract_list.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from box import Box
import gc

from PySide6 import QtCore, QtGui, QtWidgets

from fastflix.language import t
Expand Down Expand Up @@ -47,6 +48,8 @@ def resizeEvent(self, event: QtGui.QResizeEvent):
return super().resizeEvent(event)

def _new_source(self, widgets):
self.inner_widget.close()
del self.inner_widget
self.inner_widget = QtWidgets.QWidget()

layout = QtWidgets.QVBoxLayout()
Expand Down Expand Up @@ -116,9 +119,11 @@ def get_settings(self):
raise NotImplementedError()

def remove_track(self, track):
self.tracks.pop(self.tracks.index(track))
del self.tracks[self.tracks.index(track)]
track.close()
del track
self.reorder()
gc.collect(2)

def remove_all(self):
for widget in self.tracks:
Expand Down

0 comments on commit 80cca41

Please sign in to comment.