Skip to content

Commit

Permalink
* Adding #178 selector for number of autocrop positions throughout vi…
Browse files Browse the repository at this point in the history
…deo (thanks to bmcassagne)
  • Loading branch information
cdgriffith committed Jan 13, 2021
1 parent 4af781c commit 6866bc3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Version 4.2.0

* Adding #178 selector for number of autocrop positions throughout video (thanks to bmcassagne)

## Version 4.1.1

* Fixing #156 Copy was broken due to copy settings being renamed due to library update (thanks to leonardyan)
Expand Down
1 change: 1 addition & 0 deletions fastflix/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class Config(BaseModel):
flat_ui: bool = True
language: str = "en"
logging_level: int = 10
crop_detect_points: int = 10
continue_on_failure: bool = True
work_path: Path = fastflix_folder
use_sane_audio: bool = True
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__ = "4.1.1"
__version__ = "4.2.0b0"
__author__ = "Chris Griffith"
6 changes: 4 additions & 2 deletions fastflix/widgets/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,15 +781,17 @@ def get_auto_crop(self):

start_pos = self.start_time or self.app.fastflix.current_video.duration // 10

blocks = math.ceil((self.app.fastflix.current_video.duration - start_pos) / 5)
blocks = math.ceil(
(self.app.fastflix.current_video.duration - start_pos) / (self.app.fastflix.config.crop_detect_points + 1)
)
if blocks < 1:
blocks = 1

times = [
x
for x in range(int(start_pos), int(self.app.fastflix.current_video.duration), blocks)
if x < self.app.fastflix.current_video.duration
][:4]
][: self.app.fastflix.config.crop_detect_points]

if not times:
return
Expand Down
16 changes: 15 additions & 1 deletion fastflix/widgets/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
language_list = sorted((k for k, v in Lang._data["name"].items() if v["pt2B"] and v["pt1"]), key=lambda x: x.lower())

known_language_list = ["English", "Chinese", "Italian", "French", "Spanish", "German"]
possible_detect_points = ["1", "2", "4", "6", "8", "10", "15", "20", "25", "50", "100"]

# "Japanese", "Korean", "Hindi", "Russian", "Portuguese"

Expand Down Expand Up @@ -105,18 +106,30 @@ def __init__(self, app: FastFlixApp, main, *args, **kwargs):
self.flat_ui = QtWidgets.QCheckBox(t("Flat UI"))
self.flat_ui.setChecked(self.app.fastflix.config.flat_ui)

self.crop_detect_points_widget = QtWidgets.QComboBox()
self.crop_detect_points_widget.addItems(possible_detect_points)

try:
self.crop_detect_points_widget.setCurrentIndex(
possible_detect_points.index(str(self.app.fastflix.config.crop_detect_points))
)
except ValueError:
self.crop_detect_points_widget.setCurrentIndex(5)

layout.addWidget(self.use_sane_audio, 7, 0, 1, 2)
layout.addWidget(self.disable_version_check, 8, 0, 1, 2)
layout.addWidget(QtWidgets.QLabel(t("GUI Logging Level")), 9, 0)
layout.addWidget(self.logger_level_widget, 9, 1)
layout.addWidget(self.flat_ui, 10, 0, 1, 2)
layout.addWidget(QtWidgets.QLabel(t("Crop Detect Points")), 11, 0, 1, 1)
layout.addWidget(self.crop_detect_points_widget, 11, 1, 1, 1)

button_layout = QtWidgets.QHBoxLayout()
button_layout.addStretch()
button_layout.addWidget(cancel)
button_layout.addWidget(save)

layout.addLayout(button_layout, 11, 0, 1, 3)
layout.addLayout(button_layout, 12, 0, 1, 3)

self.setLayout(layout)

Expand Down Expand Up @@ -153,6 +166,7 @@ def save(self):
log_level = (self.logger_level_widget.currentIndex() + 1) * 10
self.app.fastflix.config.logging_level = log_level
logger.setLevel(log_level)
self.app.fastflix.config.crop_detect_points = int(self.crop_detect_points_widget.currentText())

self.main.config_update()
self.app.fastflix.config.save()
Expand Down

0 comments on commit 6866bc3

Please sign in to comment.