Skip to content

Commit

Permalink
Adding improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cdgriffith committed Feb 9, 2024
1 parent b37476d commit 88b44f0
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 10 deletions.
2 changes: 2 additions & 0 deletions fastflix/encoders/copy/command_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def build(fastflix: FastFlix):
rotation = abs(int(fastflix.current_video.current_video_stream.side_data_list[0].rotation))

rot = ""
# if fastflix.current_video.video_settings.rotate != 0:
# rot = f"-display_rotation:s:v {rotation + (fastflix.current_video.video_settings.rotate * 90)}"
if fastflix.current_video.video_settings.output_path.name.lower().endswith("mp4"):
rot = f"-metadata:s:v rotate={rotation + (fastflix.current_video.video_settings.rotate * 90)}"

Expand Down
21 changes: 16 additions & 5 deletions fastflix/flix.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

logger = logging.getLogger("fastflix")

HDR10_parser_version = None

ffmpeg_valid_color_primaries = [
"bt709",
"bt470m",
Expand Down Expand Up @@ -558,16 +560,25 @@ def parse_hdr_details(app: FastFlixApp, **_):
)


def get_hdr10_parser_version(config: Config) -> LooseVersion:
global HDR10_parser_version
if HDR10_parser_version:
return HDR10_parser_version
HDR10_parser_version_output = check_output([str(config.hdr10plus_parser), "--version"], encoding="utf-8")

_, version_string = HDR10_parser_version_output.rsplit(sep=" ", maxsplit=1)
HDR10_parser_version = LooseVersion(version_string)
logger.debug(f"Using HDR10 parser version {str(HDR10_parser_version).strip()}")
return HDR10_parser_version


def detect_hdr10_plus(app: FastFlixApp, config: Config, **_):
if not config.hdr10plus_parser or not config.hdr10plus_parser.exists():
return

hdr10plus_streams = []

hdr10_parser_version_output = check_output([str(config.hdr10plus_parser), "--version"], encoding="utf-8")
_, version_string = hdr10_parser_version_output.rsplit(sep=" ", maxsplit=1)
hdr10_parser_version = LooseVersion(version_string)
logger.debug(f"Using HDR10 parser version {str(hdr10_parser_version).strip()}")
parser_version = get_hdr10_parser_version(config)

for stream in app.fastflix.current_video.streams.video:
logger.debug(f"Checking for hdr10+ in stream {stream.index}")
Expand Down Expand Up @@ -595,7 +606,7 @@ def detect_hdr10_plus(app: FastFlixApp, config: Config, **_):
)

hdr10_parser_command = [str(config.hdr10plus_parser), "--verify", "-"]
if hdr10_parser_version >= LooseVersion("1.0.0"):
if parser_version >= LooseVersion("1.0.0"):
hdr10_parser_command.insert(-1, "extract")

process_two = Popen(
Expand Down
1 change: 1 addition & 0 deletions fastflix/widgets/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,7 @@ def update_video_info(self, hide_progress=False):

self.widgets.deinterlace.setChecked(self.app.fastflix.current_video.video_settings.deinterlace)

logger.info("Updating video info")
self.video_options.new_source()
self.enable_all()
# self.widgets.convert_button.setDisabled(False)
Expand Down
4 changes: 3 additions & 1 deletion fastflix/widgets/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from PySide6 import QtCore, QtWidgets

from fastflix.language import t
from fastflix.models.fastflix_app import FastFlixApp

logger = logging.getLogger("fastflix")

Expand All @@ -24,7 +25,7 @@ class ProgressBar(QtWidgets.QFrame):

def __init__(
self,
app: QtWidgets.QApplication,
app: FastFlixApp,
tasks: list[Task],
signal_task: bool = False,
auto_run: bool = True,
Expand Down Expand Up @@ -86,6 +87,7 @@ def run(self):

else:
for i, task in enumerate(self.tasks, start=1):
logger.info(f"Running task {task.name}")
self.status.setText(task.name)
self.app.processEvents()
if self.app.fastflix.shutting_down:
Expand Down
1 change: 1 addition & 0 deletions fastflix/widgets/video_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def new_source(self):
self.current_settings.new_source()
self.queue.new_source()
self.advanced.new_source()
# TODO disable on loading from directory
self.info.reset()
self.debug.reset()

Expand Down
22 changes: 18 additions & 4 deletions fastflix/widgets/windows/hdr10plus_inject.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import logging
import secrets
from subprocess import run, PIPE

from PySide6 import QtWidgets, QtGui, QtCore
from PySide6.QtWidgets import QAbstractItemView
Expand Down Expand Up @@ -57,10 +58,10 @@ def __init__(self, app, main, items=None):
line_3.addWidget(self.hdr10p_file_button)

self.info_bubble = QtWidgets.QLabel("")
self.command_bubble = QtWidgets.QLabel("")
self.command_bubble = QtWidgets.QLineEdit("")
self.command_bubble.setFixedWidth(400)
self.command_bubble.setWordWrap(True)
self.command_bubble.setFixedHeight(400)
# self.command_bubble.setWordWrap(True)
# self.command_bubble.setFixedHeight(400)

layout = QtWidgets.QVBoxLayout()

Expand All @@ -69,11 +70,20 @@ def __init__(self, app, main, items=None):
output_lin.addWidget(self.output_file)
output_lin.addWidget(self.output_file_button)

bottom_line = QtWidgets.QHBoxLayout()
cancel = QtWidgets.QPushButton("Cancel")
cancel.clicked.connect(self.hide)
bottom_line.addWidget(cancel)
start = QtWidgets.QPushButton("Start")
start.clicked.connect(self.start)
bottom_line.addWidget(start)

layout.addLayout(line_1)
layout.addWidget(self.info_bubble)
layout.addLayout(line_3)
layout.addLayout(output_lin)
layout.addWidget(self.command_bubble)
layout.addLayout(bottom_line)
self.setLayout(layout)

def movie_open(self):
Expand Down Expand Up @@ -129,6 +139,10 @@ def prep_command(self):
f"{self.app.fastflix.config.hdr10plus_parser} inject -i - -j {self.hdr10p_file.text()} -o - | "
f'{self.app.fastflix.config.ffmpeg} -loglevel panic -i - -i {self.movie_file.text()} -map 0:0 -c:0 copy -map 1:a -map 1:s -map 1:d -c:1 copy "{self.output_file.text()}"'
)
print(command)

print(command)
self.command_bubble.setText(command)

def start(self):
run(self.command_bubble.text(), shell=True)
error_message("Done")

0 comments on commit 88b44f0

Please sign in to comment.