Skip to content

Commit

Permalink
Version 2.5.0 (#56)
Browse files Browse the repository at this point in the history
* Adding settings dialog
* Fixing no bitrate should be specified for lossless audio
  • Loading branch information
cdgriffith authored Aug 29, 2020
1 parent 0e4309b commit 19efaee
Show file tree
Hide file tree
Showing 18 changed files with 318 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
- id: check-byte-order-marker
- id: debug-statements
- repo: https://github.com/psf/black
rev: stable
rev: 20.8b1
hooks:
- id: black
# - repo: https://github.com/pre-commit/mirrors-mypy
Expand Down
8 changes: 7 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
Changelog
---------

Version 2.5.0
~~~~~~~~~~~~~

* Adding settings dialog
* Fixing no bitrate should be specified for lossless audio

Version 2.4.1
~~~~~~~~~~~~~

* Fixing HEVC custom CRF issue
* Fixing #52 HEVC custom CRF issue (thanks to 2600box)

Version 2.4.0
~~~~~~~~~~~~~
Expand Down
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,25 @@ build_script:
after_build:
- cmd: move dist\*.exe .
- cmd: move docs\build-licenses.txt LICENSE
- cmd: 7z a FastFlix_%VERSION%.zip FastFlix*exe LICENSE
- cmd: 7z a FastFlix_%VERSION%_win64.zip FastFlix*exe LICENSE

test: off

artifacts:
- path: 'FastFlix_%VERSION%.zip'
- path: 'FastFlix_%VERSION%_win64.zip'

deploy:
- provider: Environment
name: pre-release
artifact: 'FastFlix_%VERSION%.zip'
artifact: 'FastFlix_%VERSION%_win64.zip'
description: ''
on:
branch:
- develop

- provider: Environment
name: release
artifact: 'FastFlix_%VERSION%.zip'
artifact: 'FastFlix_%VERSION%_win64.zip'
description: ''
on:
branch:
Expand Down
23 changes: 20 additions & 3 deletions fastflix/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import shutil
import traceback
from json import JSONDecodeError

try:
import pkg_resources.py2_warn # Needed for pyinstaller on 3.8
Expand All @@ -25,7 +26,7 @@

from fastflix.version import __version__
from fastflix.flix import ff_version, FlixError
from fastflix.shared import error_message, base_path
from fastflix.shared import error_message, base_path, message
from fastflix.widgets.container import Container
except ImportError as err:
traceback.print_exc()
Expand Down Expand Up @@ -82,7 +83,22 @@ def main():
config = Box({"version": __version__, "work_dir": str(data_path)})
config.to_json(filename=config_file, indent=2)
else:
config = Box.from_json(filename=config_file)
try:
config = Box.from_json(filename=config_file)
except JSONDecodeError as err:
logger.exception(f'Error with config file: "{config_file}"')
error_message(
msg=f"Bad config file: {config_file}"
"<br> If you are unsure what to do, just delete the file"
f"<br><br>Error: {err}",
traceback=True,
)
sys.exit(1)
if "version" not in config or "work_dir" not in config:
message("Config file does not have all required fields, adding defaults")
config.version = __version__
config.work_dir = str(data_path)
config.to_json(filename=config_file, indent=2)
if StrictVersion(config.version) < StrictVersion(__version__):
# do upgrade of config
config.version = __version__
Expand Down Expand Up @@ -173,6 +189,7 @@ def main():
source=sys.argv[1] if len(sys.argv) > 1 else "",
data_path=data_path,
work_path=work_dir,
config_file=config_file,
)
window.show()
except (Exception, BaseException, SystemError, SystemExit):
Expand All @@ -195,7 +212,7 @@ def windows_download_ffmpeg(ffmpeg_folder):
ffmpeg_folder.mkdir(exist_ok=True)
url = "https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-latest-win64-static.zip"
logger.info(f"Downloading {url} to {ffmpeg_folder}")
req = requests.get(url, headers={"referer": "https://ffmpeg.zeranoe.com/"}, stream=True,)
req = requests.get(url, headers={"referer": "https://ffmpeg.zeranoe.com/"}, stream=True)
with open(ffmpeg_folder / "ffmpeg-latest-win64-static.zip", "wb") as f:
for block in req.iter_content(chunk_size=4096):
f.write(block)
Expand Down
11 changes: 9 additions & 2 deletions fastflix/plugins/av1/settings_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def mode_update(self):
self.main.build_commands()

def get_settings(self):
settings = Box(disable_hdr=bool(self.widgets.remove_hdr.currentIndex()),)
settings = Box(disable_hdr=bool(self.widgets.remove_hdr.currentIndex()))
if self.mode == "CRF":
settings.crf = int(self.widgets.crf.currentText().split(" ", 1)[0])
else:
Expand All @@ -148,10 +148,17 @@ def get_settings(self):
def new_source(self):
if not self.main.streams:
return
if self.main.streams["video"][self.main.video_track].get("color_space", "").startswith("bt2020"):
if "zcale" not in self.main.flix.filters:
self.widgets.remove_hdr.setDisabled(True)
self.remove_hdr_label.setStyleSheet("QLabel{color:#777}")
self.remove_hdr_label.setToolTip("cannot remove HDR, zcale filter not in current version of FFmpeg")
logger.warning("zcale filter not detected in current version of FFmpeg, cannot remove HDR")
elif self.main.streams["video"][self.main.video_track].get("color_space", "").startswith("bt2020"):
self.widgets.remove_hdr.setDisabled(False)
self.remove_hdr_label.setStyleSheet("QLabel{color:#000}")
else:
self.widgets.remove_hdr.setDisabled(True)
self.remove_hdr_label.setStyleSheet("QLabel{color:#000}")

def set_mode(self, x):
self.mode = x.text()
Expand Down
9 changes: 6 additions & 3 deletions fastflix/plugins/common/audio.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

lossless = ["flac", "truehd", "alac", "tta", "wavpack", "mlp"]


def build_audio(audio_tracks, audio_file_index=0):
command_list = []
Expand All @@ -16,8 +18,9 @@ def build_audio(audio_tracks, audio_file_index=0):
if track.conversion.codec == "none":
command_list.append(f"-c:{track.outdex} copy")
elif "conversion" in track:
command_list.append(
f"-c:{track.outdex} {track.conversion.codec} -b:{track.outdex} {track.conversion.bitrate} {downmix}"
)
bitrate = ""
if track.conversion.codec not in lossless:
bitrate = f"-b:{track.outdex} {track.conversion.bitrate} "
command_list.append(f"-c:{track.outdex} {track.conversion.codec} {bitrate} {downmix}")

return " ".join(command_list)
10 changes: 7 additions & 3 deletions fastflix/plugins/gif/settings_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ def get_settings(self):
def new_source(self):
if not self.main.streams:
return
if self.main.streams["video"][self.main.video_track].get("color_space", "").startswith("bt2020"):
if "zcale" not in self.main.flix.filters:
self.widgets.remove_hdr.setDisabled(True)
self.remove_hdr_label.setStyleSheet("QLabel{color:#777}")
self.remove_hdr_label.setToolTip("cannot remove HDR, zcale filter not in current version of FFmpeg")
elif self.main.streams["video"][self.main.video_track].get("color_space", "").startswith("bt2020"):
self.widgets.remove_hdr.setDisabled(False)
self.widgets.dither.setCurrentIndex(1)
self.remove_hdr_label.setStyleSheet("QLabel{color:#000}")
else:
self.widgets.dither.setCurrentIndex(0)
self.widgets.remove_hdr.setDisabled(True)
self.remove_hdr_label.setStyleSheet("QLabel{color:#000}")
self.widgets.fps.setCurrentIndex(14)
self.widgets.dither.setCurrentIndex(0)
9 changes: 8 additions & 1 deletion fastflix/plugins/svt_av1/settings_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,17 @@ def get_settings(self):
def new_source(self):
if not self.main.streams:
return
if self.main.streams["video"][self.main.video_track].get("color_space", "").startswith("bt2020"):
if "zcale" not in self.main.flix.filters:
self.widgets.remove_hdr.setDisabled(True)
self.remove_hdr_label.setStyleSheet("QLabel{color:#777}")
self.remove_hdr_label.setToolTip("cannot remove HDR, zcale filter not in current version of FFmpeg")
logger.warning("zcale filter not detected in current version of FFmpeg, cannot remove HDR")
elif self.main.streams["video"][self.main.video_track].get("color_space", "").startswith("bt2020"):
self.widgets.remove_hdr.setDisabled(False)
self.remove_hdr_label.setStyleSheet("QLabel{color:#000}")
else:
self.widgets.remove_hdr.setDisabled(True)
self.remove_hdr_label.setStyleSheet("QLabel{color:#000}")

def set_mode(self, x):
self.mode = x.text()
Expand Down
9 changes: 8 additions & 1 deletion fastflix/plugins/vp9/settings_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,17 @@ def get_settings(self):
def new_source(self):
if not self.main.streams:
return
if self.main.streams["video"][self.main.video_track].get("color_space", "").startswith("bt2020"):
if "zcale" not in self.main.flix.filters:
self.widgets.remove_hdr.setDisabled(True)
self.remove_hdr_label.setStyleSheet("QLabel{color:#777}")
self.remove_hdr_label.setToolTip("cannot remove HDR, zcale filter not in current version of FFmpeg")
logger.warning("zcale filter not detected in current version of FFmpeg, cannot remove HDR")
elif self.main.streams["video"][self.main.video_track].get("color_space", "").startswith("bt2020"):
self.widgets.remove_hdr.setDisabled(False)
self.remove_hdr_label.setStyleSheet("QLabel{color:#000}")
else:
self.widgets.remove_hdr.setDisabled(True)
self.remove_hdr_label.setStyleSheet("QLabel{color:#000}")

def set_mode(self, x):
self.mode = x.text()
Expand Down
6 changes: 3 additions & 3 deletions fastflix/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
main_width = 800


def message(msg, parent=None):
def message(msg):
sm = QtWidgets.QMessageBox()
sm.setText(msg)
sm.setStandardButtons(QtWidgets.QMessageBox.Ok)
sm.exec_()


def error_message(msg, details=None, traceback=False, parent=None):
def error_message(msg, details=None, traceback=False):
em = QtWidgets.QMessageBox()
em.setText(msg)
if details:
Expand All @@ -36,5 +36,5 @@ def error_message(msg, details=None, traceback=False, parent=None):
import traceback

em.setDetailedText(traceback.format_exc())
em.setStandardButtons(QtWidgets.QMessageBox.Ok)
em.setStandardButtons(QtWidgets.QMessageBox.Close)
em.exec_()
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__ = "2.4.0"
__version__ = "2.5.0"
__author__ = "Chris Griffith"
1 change: 0 additions & 1 deletion fastflix/widgets/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,3 @@ def __init__(self, parent=None):
layout.addWidget(license_label)

self.setLayout(layout)
self.show()
38 changes: 30 additions & 8 deletions fastflix/widgets/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,54 @@
from fastflix.widgets.main import Main
from fastflix.widgets.about import About
from fastflix.widgets.logs import Logs
from fastflix.widgets.settings import Settings


class Container(QtWidgets.QMainWindow):
def __init__(self, data_path, work_path, **kwargs):
def __init__(self, data_path, work_path, config_file, **kwargs):
super(Container, self).__init__()
self.logs = Logs()
self.about = None
self.init_menu()
main = Main(self, data_path, work_path, **kwargs)
self.setCentralWidget(main)
self.config_file = config_file
self.main = Main(self, data_path, work_path, **kwargs)
self.setCentralWidget(self.main)
self.setMinimumSize(1200, 600)
my_data = str(Path(pkg_resources.resource_filename(__name__, f"../data/icon.ico")).resolve())
icon = QtGui.QIcon(my_data)
self.setWindowIcon(icon)
self.setWindowIcon(icon)

def init_menu(self):
exit_action = QtWidgets.QAction("&Exit", self)
menubar = self.menuBar()

file_menu = menubar.addMenu("&File")

setting_action = QtWidgets.QAction(
self.style().standardIcon(QtWidgets.QStyle.SP_FileDialogListView), "&Settings", self
)
setting_action.setShortcut("Ctrl+S")
setting_action.triggered.connect(self.show_setting)

exit_action = QtWidgets.QAction(
self.style().standardIcon(QtWidgets.QStyle.SP_DialogCancelButton), "&Exit", self
)
exit_action.setShortcut(QtGui.QKeySequence("Ctrl+Q"))
exit_action.setStatusTip("Exit application")
exit_action.triggered.connect(self.close)

menubar = self.menuBar()
file_menu = menubar.addMenu("&File")
file_menu.addAction(setting_action)
file_menu.addSeparator()
file_menu.addAction(exit_action)

about_action = QtWidgets.QAction("&About", self)
about_action = QtWidgets.QAction(
self.style().standardIcon(QtWidgets.QStyle.SP_FileDialogInfoView), "&About", self
)
about_action.triggered.connect(self.show_about)

log_action = QtWidgets.QAction("View &Logs", self)
log_action = QtWidgets.QAction(
self.style().standardIcon(QtWidgets.QStyle.SP_FileDialogDetailedView), "View &Logs", self
)
log_action.triggered.connect(self.show_logs)

report_action = QtWidgets.QAction("Report &Issue", self)
Expand All @@ -51,6 +69,10 @@ def show_about(self):
self.about = About()
self.about.show()

def show_setting(self):
self.setting = Settings(self.config_file, self.main)
self.setting.show()

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

Expand Down
3 changes: 3 additions & 0 deletions fastflix/widgets/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self, parent):
super(QPlainTextEditLogger, self).__init__()
self.widget = QtWidgets.QTextBrowser(parent)
self.widget.setReadOnly(True)
self.widget.setDisabled(True)

def emit(self, record):
msg = self.format(record)
Expand All @@ -26,6 +27,7 @@ class Logs(QtWidgets.QWidget):
def __init__(self, parent=None):
super(Logs, self).__init__(parent)

self.setMinimumSize(800, 600)
layout = QtWidgets.QVBoxLayout()
log_text_box = QPlainTextEditLogger(self)
log_text_box.setFormatter(logging.Formatter("<b>%(levelname)s</b> - %(asctime)s - %(message)s"))
Expand All @@ -34,6 +36,7 @@ def __init__(self, parent=None):
logger.addHandler(log_text_box)

log_text_box.setLevel(logging.DEBUG)
layout.addWidget(QtWidgets.QLabel("Log window scrolling bug causing crashes, currently disabled for safety"))
layout.addWidget(log_text_box.widget)
self.setLayout(layout)

Expand Down
9 changes: 9 additions & 0 deletions fastflix/widgets/panels/audio_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from qtpy import QtWidgets, QtCore, QtGui
from fastflix.widgets.panels.abstract_list import FlixList
from fastflix.plugins.common.audio import lossless


class Audio(QtWidgets.QTabWidget):
Expand Down Expand Up @@ -136,6 +137,7 @@ def init_conversion(self):
[f"{x}k" for x in range(32 * self.channels, (256 * self.channels) + 1, 32 * self.channels)]
)
self.widgets.convert_bitrate.setCurrentIndex(3)
self.widgets.convert_bitrate.setDisabled(True)

self.widgets.convert_bitrate.currentIndexChanged.connect(lambda: self.page_update())
self.widgets.convert_to.currentIndexChanged.connect(self.update_conversion)
Expand Down Expand Up @@ -170,8 +172,13 @@ def update_downmix(self):
def update_conversion(self):
if self.widgets.convert_to.currentIndex() == 0:
self.widgets.downmix.setDisabled(True)
self.widgets.convert_bitrate.setDisabled(True)
else:
self.widgets.downmix.setDisabled(False)
if self.widgets.convert_to.currentText() in lossless:
self.widgets.convert_bitrate.setDisabled(True)
else:
self.widgets.convert_bitrate.setDisabled(False)
self.page_update()

def page_update(self):
Expand All @@ -193,6 +200,8 @@ def update_codecs(self, codec_list):
index += 1
self.widgets.convert_to.setCurrentIndex(index)
self.widgets.convert_to.setCurrentIndex(0) # Will either go to 'copy' or first listed
if self.widgets.convert_bitrate:
self.widgets.convert_bitrate.setDisabled(True)
self.loading = False

@property
Expand Down
Loading

0 comments on commit 19efaee

Please sign in to comment.