Skip to content

Commit

Permalink
versioning fixes, working encc encodes
Browse files Browse the repository at this point in the history
  • Loading branch information
cdgriffith committed Apr 17, 2024
1 parent 51ee9fb commit 4be813d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 55 deletions.
2 changes: 2 additions & 0 deletions fastflix/encoders/common/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
def build_audio(audio_tracks, audio_file_index=0):
command_list = []
for track in audio_tracks:
if not track.enabled:
continue
command_list.append(
f"-map {audio_file_index}:{track.index} "
f'-metadata:s:{track.outdex} title="{track.title}" '
Expand Down
2 changes: 1 addition & 1 deletion fastflix/encoders/common/encc_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def build_audio(audio_tracks: list[AudioTrack], audio_streams):
if track.conversion_bitrate:
bitrate = f"--audio-bitrate {audio_id}?{track.conversion_bitrate} "
else:
bitrate = f"--audio-profile {audio_id}?{track.conversion_aq} "
bitrate = f"--audio-quality {audio_id}?{track.conversion_aq} "
command_list.append(
f"{downmix} --audio-codec {audio_id}?{track.conversion_codec} {bitrate} "
f"--audio-metadata {audio_id}?clear"
Expand Down
10 changes: 6 additions & 4 deletions fastflix/flix.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path
from subprocess import PIPE, CompletedProcess, Popen, TimeoutExpired, run, check_output
from typing import List, Tuple, Union
from distutils.version import LooseVersion
from packaging import version
import shlex

import reusables
Expand Down Expand Up @@ -275,6 +275,8 @@ def parse(app: FastFlixApp, **_):


def extract_attachments(app: FastFlixApp, **_):
if app.fastflix.config.disable_cover_extraction:
return
for track in app.fastflix.current_video.streams.attachment:
filename = track.get("tags", {}).get("filename", "")
if filename.rsplit(".", 1)[0] in ("cover", "small_cover", "cover_land", "small_cover_land"):
Expand Down Expand Up @@ -567,14 +569,14 @@ def parse_hdr_details(app: FastFlixApp, **_):
)


def get_hdr10_parser_version(config: Config) -> LooseVersion:
def get_hdr10_parser_version(config: Config) -> version:
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)
HDR10_parser_version = version.parse(version_string)
logger.debug(f"Using HDR10 parser version {str(HDR10_parser_version).strip()}")
return HDR10_parser_version

Expand Down Expand Up @@ -613,7 +615,7 @@ def detect_hdr10_plus(app: FastFlixApp, config: Config, **_):
)

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

process_two = Popen(
Expand Down
2 changes: 2 additions & 0 deletions fastflix/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class Config(BaseModel):
sticky_tabs: bool = False
disable_complete_message: bool = False

disable_cover_extraction: bool = False

def encoder_opt(self, profile_name, profile_option_name):
encoder_settings = getattr(self.profiles[self.selected_profile], profile_name)
if encoder_settings:
Expand Down
6 changes: 3 additions & 3 deletions fastflix/widgets/background_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from pathlib import Path
from subprocess import PIPE, STDOUT, Popen, run, check_output
from distutils.version import LooseVersion
from packaging import version

from PySide6 import QtCore

Expand Down Expand Up @@ -114,7 +114,7 @@ def run(self):
[str(self.app.fastflix.config.hdr10plus_parser), "--version"], encoding="utf-8"
)
_, version_string = hdr10_parser_version_output.rsplit(sep=" ", maxsplit=1)
hdr10_parser_version = LooseVersion(version_string)
hdr10_parser_version = version.parse(version_string)
self.main.thread_logging_signal.emit(f"Using HDR10 parser version {str(hdr10_parser_version).strip()}")

ffmpeg_command = [
Expand All @@ -134,7 +134,7 @@ def run(self):
]

hdr10_parser_command = [str(self.app.fastflix.config.hdr10plus_parser), "-o", clean_file_string(output), "-"]
if hdr10_parser_version >= LooseVersion("1.0.0"):
if hdr10_parser_version >= version.parse("1.0.0"):
hdr10_parser_command.insert(1, "extract")

self.main.thread_logging_signal.emit(
Expand Down
11 changes: 1 addition & 10 deletions fastflix/widgets/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ def update_video_info(self, hide_progress=False):
self.app.fastflix.current_video = Video(source=self.input_video, work_path=self.get_temp_work_path())
tasks = [
Task(t("Parse Video details"), parse),
# Task(t("Extract covers"), extract_attachments),
Task(t("Extract covers"), extract_attachments),
Task(t("Detecting Interlace"), detect_interlaced, dict(source=self.source_material)),
Task(t("Determine HDR details"), parse_hdr_details),
Task(t("Detect HDR10+"), detect_hdr10_plus),
Expand Down Expand Up @@ -2141,12 +2141,3 @@ def run(self):
return
self.main.status_update_signal.emit(status)
self.app.processEvents()
# if status[0] == "complete":
# logger.debug("GUI received status queue complete")
# self.main.completed.emit(0)
# elif status[0] == "error":
# logger.debug("GUI received status queue errored")
# self.main.completed.emit(1)
# elif status[0] == "cancelled":
# logger.debug("GUI received status queue errored")
# self.main.cancelled.emit("|".join(status[1:]))
37 changes: 0 additions & 37 deletions fastflix/widgets/panels/subtitle_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,6 @@ def __init__(self, app, parent, index, enabled=True, first=False):
self.updating_burn = False
self.extract_completed_signal.connect(self.extraction_complete)

# def set_dis_button(self):
# output = ""
# for disposition, is_set in self.dispositions.items():
# if is_set:
# output += f"{t(disposition)},"
# if output:
# self.widgets.disposition.setText(output.rstrip(","))
# else:
# self.widgets.disposition.setText(t("none"))

def extraction_complete(self):
self.grid.addWidget(self.widgets.extract, 0, 3)
self.movie.stop()
Expand Down Expand Up @@ -210,10 +200,6 @@ def set_outdex(self, outdex):
else:
self.widgets.track_number.setText(f"{sub_track.index}:{sub_track.outdex}")

# @property
# def disposition(self):
# return None

@property
def enabled(self):
return self.app.fastflix.current_video.subtitle_tracks[self.index].enabled
Expand Down Expand Up @@ -369,28 +355,6 @@ def new_source(self):
def get_settings(self):
return # TODO remove

# def get_settings(self):
# tracks = []
# burn_in_count = 0
# for track in self.tracks:
# if track.enabled:
# tracks.append(
# SubtitleTrack(
# index=track.index,
# outdex=track.outdex,
# dispositions=track.dispositions,
# language=track.language,
# burn_in=track.burn_in,
# subtitle_type=track.subtitle_type,
# )
# )
# if track.burn_in:
# burn_in_count += 1
# if burn_in_count > 1:
# raise FastFlixInternalException(t("More than one track selected to burn in"))
# clear_list(self.app.fastflix.current_video.subtitle_tracks)
# self.app.fastflix.current_video.subtitle_tracks = tracks

def reload(self, original_tracks):
clear_list(self.tracks)

Expand All @@ -399,7 +363,6 @@ def reload(self, original_tracks):
Subtitle(
app=self.app,
parent=self,
subtitle=track,
index=i,
first=True if i == 0 else False,
enabled=track.enabled,
Expand Down

0 comments on commit 4be813d

Please sign in to comment.