Skip to content

Commit

Permalink
Version 4.2.1 (#222)
Browse files Browse the repository at this point in the history
* Adding support for source_directory and output_name_format in config file (thanks to cwills75)
* Fixing #129 no subtitles should be enabled, removing need for mkvpropedit (thanks to wiedemanu)
* Fixing network paths not working on Windows
* Changing difference between requirements and requirements-build and removing the build version
  • Loading branch information
cdgriffith authored May 11, 2021
1 parent 070e4b8 commit 1ed0a16
Show file tree
Hide file tree
Showing 18 changed files with 66 additions and 151 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- name: Insatll requirements
run: |
python -m pip install --upgrade pip setuptools --ignore-installed
python -m pip install --upgrade wheel typing_extensions
python -m pip install -r requirements-build.txt
python -m pip install --upgrade wheel typing_extensions pyinstaller==4.3
python -m pip install -r requirements.txt
python -m pip install --upgrade pyqt5-tools
- name: Grab iso-639 lists
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_linux_legacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- name: Insatll requirements
run: |
python -m pip install --upgrade pip setuptools --ignore-installed
python -m pip install --upgrade wheel typing_extensions
python -m pip install -r requirements-build.txt
python -m pip install --upgrade wheel typing_extensions pyinstaller==4.3
python -m pip install -r requirements.txt
python -m pip install --upgrade pyqt5-tools
- name: Grab iso-639 lists
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_mac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- name: Insatll requirements
run: |
python -m pip install --upgrade pip setuptools --ignore-installed
python -m pip install --upgrade wheel typing_extensions
python -m pip install -r requirements-build.txt
python -m pip install --upgrade wheel typing_extensions pyinstaller==4.3
python -m pip install -r requirements.txt
- name: Grab iso-639 lists
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
shell: cmd
run: |
python -m pip install --upgrade pip setuptools --ignore-installed
python -m pip install --upgrade pypiwin32 wheel typing_extensions
python -m pip install -r requirements-build.txt
python -m pip install --upgrade pypiwin32 wheel typing_extensions pyinstaller==4.2
python -m pip install -r requirements.txt
- name: Grab iso-639 lists
shell: powershell
Expand Down
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Version 4.2.1

* Adding support for source_directory and output_name_format in config file (thanks to cwills75)
* Fixing #129 no subtitles should be enabled, removing need for mkvpropedit (thanks to wiedemanu)
* Fixing network paths not working on Windows
* Changing difference between requirements and requirements-build and removing the build version

## Version 4.2.0

* Adding #109 NVENC HEVC support based on FFmpeg (thanks to Zeid164)
Expand Down
2 changes: 1 addition & 1 deletion FastFlix_Nix_OneFile.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ for root, dirs, files in os.walk('fastflix'):
all_fastflix_files.append((os.path.join(root,file), root))

all_imports = collect_submodules('pydantic') + ['dataclasses', 'colorsys', 'typing_extensions']
with open("requirements-build.txt", "r") as reqs:
with open("requirements.txt", "r") as reqs:
for line in reqs:
package = line.split("=")[0].split(">")[0].split("<")[0].replace('"', '').replace("'", '').strip()
if package not in ("pyinstaller", "pypiwin32"):
Expand Down
2 changes: 1 addition & 1 deletion FastFlix_Windows_Installer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ for root, dirs, files in os.walk('fastflix'):
all_fastflix_files.append((os.path.join(root,file), root))

all_imports = collect_submodules('pydantic') + ['dataclasses', 'colorsys', 'typing_extensions']
with open("requirements-build.txt", "r") as reqs:
with open("requirements.txt", "r") as reqs:
for line in reqs:
package = line.split("=")[0].split(">")[0].split("<")[0].replace('"', '').replace("'", '').strip()
if package not in ("pyinstaller", "pypiwin32"):
Expand Down
2 changes: 1 addition & 1 deletion FastFlix_Windows_OneFile.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ for root, dirs, files in os.walk('fastflix'):
all_fastflix_files.append((os.path.join(root,file), root))

all_imports = collect_submodules('pydantic') + ['dataclasses', 'colorsys', 'typing_extensions']
with open("requirements-build.txt", "r") as reqs:
with open("requirements.txt", "r") as reqs:
for line in reqs:
package = line.split("=")[0].split(">")[0].split("<")[0].replace('"', '').replace("'", '').strip()
if package not in ("pyinstaller"):
Expand Down
54 changes: 1 addition & 53 deletions fastflix/command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
class BackgroundRunner:
def __init__(self, log_queue):
self.process = None
self.process_two = None
self.killed = False
self.output_file = None
self.error_output_file = None
Expand All @@ -45,7 +44,7 @@ def start_exec(self, command, work_dir: str = None, shell: bool = False, errors=
self.success_message = successes
logger.info(f"Running command: {command}")
self.process = Popen(
shlex.split(command) if not shell and isinstance(command, str) else command,
shlex.split(command.replace("\\", "\\\\")) if not shell and isinstance(command, str) else command,
shell=shell,
cwd=work_dir,
stdout=open(self.output_file, "w"),
Expand All @@ -58,39 +57,6 @@ def start_exec(self, command, work_dir: str = None, shell: bool = False, errors=

Thread(target=self.read_output).start()

def start_piped_exec(self, command_one, command_two, work_dir, errors=(), successes=()):
self.clean()
logger.info(f"Running commands: {' '.join(command_one)} | {' '.join(command_two)}")
Path(work_dir).mkdir(exist_ok=True, parents=True)
self.output_file = Path(work_dir) / f"encoder_output_{secrets.token_hex(6)}.log"
self.error_output_file = Path(work_dir) / f"encoder_error_output_{secrets.token_hex(6)}.log"
self.output_file.touch(exist_ok=True)
self.error_output_file.touch(exist_ok=True)
self.error_message = errors
self.success_message = successes

self.process = Popen(
command_one,
cwd=work_dir,
stdout=PIPE,
stderr=PIPE,
stdin=PIPE, # FFmpeg can try to read stdin and wrecks havoc on linux
)

self.process_two = Popen(
command_two,
cwd=work_dir,
stdout=open(self.output_file, "w"),
stderr=open(self.error_output_file, "w"),
stdin=self.process.stdout,
encoding="utf-8",
)

self.error_detected = False
self.started_at = datetime.datetime.now(datetime.timezone.utc)

Thread(target=self.read_output).start()

def read_output(self):
with open(self.output_file, "r", encoding="utf-8", errors="ignore") as out_file, open(
self.error_output_file, "r", encoding="utf-8", errors="ignore"
Expand Down Expand Up @@ -141,31 +107,17 @@ def read(self, limit=None):
def is_alive(self):
if not self.process:
return False
if self.process_two:
# TODO make sure process 1 dies cleanly
return True if self.process_two.poll() is None else False
return True if self.process.poll() is None else False

def clean(self):
self.kill(log=False)
self.process = None
self.process_two = None
self.error_detected = False
self.success_detected = False
self.killed = False
self.started_at = None

def kill(self, log=True):
if self.process_two and self.process_two.poll() is None:
if log:
logger.info(f"Killing worker process {self.process_two.pid}")
try:
self.process_two.terminate()
self.process_two.kill()
except Exception as err:
if log:
logger.exception(f"Couldn't terminate process: {err}")

if self.process and self.process.poll() is None:
if log:
logger.info(f"Killing worker process {self.process.pid}")
Expand All @@ -182,15 +134,11 @@ def kill(self, log=True):
self.killed = True

def pause(self):
if self.process_two:
return False
if not self.process:
return False
self.process.suspend()

def resume(self):
if self.process_two:
return False
if not self.process:
return False
self.process.resume()
6 changes: 5 additions & 1 deletion fastflix/encoders/common/subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def build_subtitle(
command_list = []
burn_in_track = None
burn_in_type = None
subs_enabled = False
for track in subtitle_tracks:
if track.burn_in:
burn_in_track = track.index
Expand All @@ -21,8 +22,11 @@ def build_subtitle(
command_list.append(f"-map {subtitle_file_index}:{track.index} -c:{outdex} copy ")
if track.disposition:
command_list.append(f"-disposition:{outdex} {track.disposition}")
if track.disposition in ("default", "forced"):
subs_enabled = True
else:
command_list.append(f"-disposition:{outdex} 0")
command_list.append(f"-metadata:s:{outdex} language='{track.language}'")

if not subs_enabled:
command_list.append("-default_mode infer_no_subs")
return " ".join(command_list), burn_in_track, burn_in_type
2 changes: 1 addition & 1 deletion fastflix/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


def separate_app_process(worker_queue, status_queue, log_queue, queue_list, queue_lock):
""" This prevents any QT components being imported in the main process"""
"""This prevents any QT components being imported in the main process"""
from fastflix.application import start_app

freeze_support()
Expand Down
8 changes: 4 additions & 4 deletions fastflix/flix.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def execute(command: List, work_dir: Union[Path, str] = None, timeout: int = Non


def ffmpeg_configuration(app, config: Config, **_):
""" Extract the version and libraries available from the specified version of FFmpeg """
"""Extract the version and libraries available from the specified version of FFmpeg"""
res = execute([f"{config.ffmpeg}", "-version"])
if res.returncode != 0:
raise FlixError(f'"{config.ffmpeg}" file not found')
Expand All @@ -108,7 +108,7 @@ def ffmpeg_configuration(app, config: Config, **_):


def ffprobe_configuration(app, config: Config, **_):
""" Extract the version of ffprobe """
"""Extract the version of ffprobe"""
res = execute([f"{config.ffprobe}", "-version"])
if res.returncode != 0:
raise FlixError(f'"{config.ffprobe}" file not found')
Expand All @@ -120,7 +120,7 @@ def ffprobe_configuration(app, config: Config, **_):


def probe(app: FastFlixApp, file: Path) -> Box:
""" Run FFprobe on a file """
"""Run FFprobe on a file"""
command = [
f"{app.fastflix.config.ffprobe}",
"-v",
Expand Down Expand Up @@ -273,7 +273,7 @@ def get_auto_crop(


def detect_interlaced(app: FastFlixApp, config: Config, source: Path, **_):
""" http://www.aktau.be/2013/09/22/detecting-interlaced-video-with-ffmpeg/ """
"""http://www.aktau.be/2013/09/22/detecting-interlaced-video-with-ffmpeg/"""

# Interlaced
# [Parsed_idet_0 @ 00000] Repeated Fields: Neither: 815 Top: 88 Bottom: 98
Expand Down
11 changes: 5 additions & 6 deletions fastflix/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,12 @@ class Config(BaseModel):
ffmpeg: Path = Field(default_factory=lambda: find_ffmpeg_file("ffmpeg"))
ffprobe: Path = Field(default_factory=lambda: find_ffmpeg_file("ffprobe"))
hdr10plus_parser: Optional[Path] = Field(default_factory=lambda: where("hdr10plus_parser"))
mkvpropedit: Optional[Path] = Field(default_factory=lambda: where("mkvpropedit"))
nvencc: Optional[Path] = Field(default_factory=lambda: where("NVEncC"))
output_directory: Optional[Path] = False
source_directory: Optional[Path] = False
output_name_format: str = "{source}-fastflix-{rand_4}.{ext}"
flat_ui: bool = True
language: str = "en"
language: str = "eng"
logging_level: int = 10
crop_detect_points: int = 10
continue_on_failure: bool = True
Expand Down Expand Up @@ -194,7 +195,7 @@ def load(self):
"there may be non-recoverable errors while loading it."
)

paths = ("work_path", "ffmpeg", "ffprobe", "hdr10plus_parser", "mkvpropedit", "nvencc", "output_directory")
paths = ("work_path", "ffmpeg", "ffprobe", "hdr10plus_parser", "nvencc", "output_directory", "source_directory")
for key, value in data.items():
if key == "profiles":
self.profiles = {}
Expand Down Expand Up @@ -233,10 +234,8 @@ def load(self):
raise err from None
if not self.hdr10plus_parser:
self.hdr10plus_parser = where("hdr10plus_parser")
if not self.mkvpropedit:
self.mkvpropedit = where("mkvpropedit")
if not self.nvencc:
self.mkvpropedit = where("NVEncC")
self.nvencc = where("NVEncC")
self.profiles.update(get_preset_defaults())

if self.selected_profile not in self.profiles:
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.2.0"
__version__ = "4.2.1"
__author__ = "Chris Griffith"
27 changes: 1 addition & 26 deletions fastflix/widgets/background_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

logger = logging.getLogger("fastflix")

__all__ = ["ThumbnailCreator", "ExtractSubtitleSRT", "SubtitleFix", "ExtractHDR10"]
__all__ = ["ThumbnailCreator", "ExtractSubtitleSRT", "ExtractHDR10"]


class ThumbnailCreator(QtCore.QThread):
Expand Down Expand Up @@ -40,31 +40,6 @@ def run(self):
self.main.thumbnail_complete.emit(1)


class SubtitleFix(QtCore.QThread):
def __init__(self, main, mkv_prop_edit, video_path):
super().__init__(main)
self.main = main
self.mkv_prop_edit = mkv_prop_edit
self.video_path = video_path

def run(self):
output_file = clean_file_string(self.video_path)
self.main.thread_logging_signal.emit(f'INFO:{t("Will fix first subtitle track to not be default")}')
try:
result = run(
[self.mkv_prop_edit, output_file, "--edit", "track:s1", "--set", "flag-default=0"],
stdout=PIPE,
stderr=STDOUT,
)
except Exception as err:
self.main.thread_logging_signal.emit(f'ERROR:{t("Could not fix first subtitle track")} - {err}')
else:
if result.returncode != 0:
self.main.thread_logging_signal.emit(
f'WARNING:{t("Could not fix first subtitle track")}: {result.stdout}'
)


class ExtractSubtitleSRT(QtCore.QThread):
def __init__(self, app: FastFlixApp, main, index, signal):
super().__init__(main)
Expand Down
Loading

0 comments on commit 1ed0a16

Please sign in to comment.