Skip to content

Commit

Permalink
Version 4.3.1 (#257)
Browse files Browse the repository at this point in the history
* Adding VCEEncC decoder option
* Adding support for HDR10+ parser version 1.0.0 and above
* Fixing VCEEncC interlace being passed "False" string
* Fixing VCEEncC was not being passed profile option
* Fixing keep / remove chapters and metadata were not explicit in both cases
  • Loading branch information
cdgriffith authored Sep 7, 2021
1 parent e0f2a15 commit 84b337f
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/black.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
- uses: actions/checkout@v2

- run: sudo apt install python3-pip python3-setuptools -y
- run: pip3 install black
- run: pip3 install black==21.8b0
- run: python3 -m black --check .
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.0.1
hooks:
- id: mixed-line-ending
- id: trailing-whitespace
Expand All @@ -23,7 +23,7 @@ repos:
# hooks:
# - id: isort
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 21.8b0
hooks:
- id: black
# - repo: https://github.com/pre-commit/mirrors-mypy
Expand Down
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## Version 4.3.1

* Adding VCEEncC decoder option
* Adding support for HDR10+ parser version 1.0.0 and above
* Fixing VCEEncC interlace being passed "False" string
* Fixing VCEEncC was not being passed profile option
* Fixing keep / remove chapters and metadata were not explicit in both cases

## Version 4.3.0

* Adding VCEEncC encoder support for HEVC and AVC
Expand Down
4 changes: 3 additions & 1 deletion fastflix/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ def init_encoders(app: FastFlixApp, **_):
encoders.insert(7, nvencc_avc_plugin)

if app.fastflix.config.vceencc:
encoders.insert(1, vceencc_hevc_plugin)
if reusables.win_based:
# HEVC AMF support only works on windows currently
encoders.insert(1, vceencc_hevc_plugin)
encoders.insert(7, vceencc_avc_plugin)

app.fastflix.encoders = {
Expand Down
2 changes: 1 addition & 1 deletion fastflix/command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def read_output(self):
if err_line:
logger.info(err_line)
self.log_queue.put(err_line)
if "Conversion failed!" in err_line:
if "Conversion failed!" in err_line or "Error during output" in err_line:
self.error_detected = True
if not self.error_detected:
for error in self.error_message:
Expand Down
21 changes: 21 additions & 0 deletions fastflix/data/languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3197,3 +3197,24 @@ Profile:
ita: profilo
spa: perfil
zho: 方案
Decoder:
deu: Decoder
eng: Decoder
fra: Décodeur
ita: Decoder
spa: Decodificador
zho: 解码器
'Hardware: use libavformat + hardware decoder for input':
deu: 'Hardware: Verwendung von libavformat + Hardware-Decoder für die Eingabe'
eng: 'Hardware: use libavformat + hardware decoder for input'
fra: "Hardware : utiliser libavformat + décodeur matériel pour l'entrée"
ita: "Hardware: usa libavformat + decoder hardware per l'ingresso"
spa: 'Hardware: utilizar libavformat + decodificador de hardware para la entrada'
zho: 'Hardware:使用libavformat+硬件解码器进行输入'
'Software: use avcodec + software decoder':
deu: 'Software: Verwendung von avcodec + Software-Decoder'
eng: 'Software: use avcodec + software decoder'
fra: 'Software : utiliser avcodec + décodeur logiciel'
ita: 'Software: usa avcodec + decoder software'
spa: 'Software: utilizar avcodec + decodificador de software'
zho: 'Software:使用avcodec + 软件解码器'
4 changes: 2 additions & 2 deletions fastflix/encoders/common/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def generate_ending(
**_,
) -> str:
ending = (
f" {'-map_metadata -1' if remove_metadata else ''} "
f"{'-map_chapters 0' if copy_chapters else ''} "
f" {'-map_metadata -1' if remove_metadata else '-map_metadata 0'} "
f"{'-map_chapters 0' if copy_chapters else '-map_chapters -1'} "
f"{f'-r {output_fps}' if output_fps else ''} "
f"{audio} {subtitles} {cover} "
)
Expand Down
5 changes: 4 additions & 1 deletion fastflix/encoders/vceencc_avc/command_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def build(fastflix: FastFlix):

command = [
f'"{clean_file_string(fastflix.config.vceencc)}"',
("--avhw" if settings.decoder == "Hardware" else "--avsw"),
"-i",
f'"{clean_file_string(video.source)}"',
(f"--video-streamid {stream_id}" if stream_id else ""),
Expand All @@ -89,6 +90,8 @@ def build(fastflix: FastFlix):
(f"--ref {settings.ref}" if settings.ref else ""),
"--preset",
settings.preset,
"--profile",
settings.profile,
"--colormatrix",
(video.video_settings.color_space or "auto"),
"--transfer",
Expand All @@ -105,7 +108,7 @@ def build(fastflix: FastFlix):
"--colorrange",
"auto",
f"--avsync {'cfr' if video.frame_rate == video.average_frame_rate else 'vfr'}",
(f"--interlace {video.interlaced}" if video.interlaced else ""),
(f"--interlace {video.interlaced}" if video.interlaced and video.interlaced != "False" else ""),
("--vpp-yadif" if video.video_settings.deinterlace else ""),
(f"--vpp-colorspace hdr2sdr=mobius" if video.video_settings.remove_hdr else ""),
remove_hdr,
Expand Down
13 changes: 13 additions & 0 deletions fastflix/encoders/vceencc_avc/settings_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def __init__(self, parent, main, app: FastFlixApp):
qp_line.addStretch(1)
qp_line.addLayout(self.init_level())
qp_line.addStretch(1)
qp_line.addLayout(self.init_decoder())
qp_line.addStretch(1)
qp_line.addLayout(self.init_metrics())
grid.addLayout(qp_line, 5, 0, 1, 6)

Expand Down Expand Up @@ -233,6 +235,16 @@ def init_ref(self):
min_width=60,
)

def init_decoder(self):
return self._add_combo_box(
widget_name="decoder",
label="Decoder",
options=["Hardware", "Software"],
opt="decoder",
tooltip="Hardware: use libavformat + hardware decoder for input\nSoftware: use avcodec + software decoder",
min_width=80,
)

def init_metrics(self):
return self._add_check_box(
widget_name="metrics",
Expand Down Expand Up @@ -273,6 +285,7 @@ def update_video_encoder_settings(self):
pre_encode=self.widgets.pre_encode.isChecked(),
pre_analysis=self.widgets.pre_analysis.isChecked(),
vbaq=self.widgets.vbaq.isChecked(),
decoder=self.widgets.decoder.currentText(),
)

encode_type, q_value = self.get_mode_settings()
Expand Down
3 changes: 2 additions & 1 deletion fastflix/encoders/vceencc_hevc/command_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def build(fastflix: FastFlix):

command = [
f'"{clean_file_string(fastflix.config.vceencc)}"',
("--avhw" if settings.decoder == "Hardware" else "--avsw"),
"-i",
f'"{clean_file_string(video.source)}"',
(f"--video-streamid {stream_id}" if stream_id else ""),
Expand Down Expand Up @@ -129,7 +130,7 @@ def build(fastflix: FastFlix):
"--colorrange",
"auto",
f"--avsync {'cfr' if video.frame_rate == video.average_frame_rate else 'vfr'}",
(f"--interlace {video.interlaced}" if video.interlaced else ""),
(f"--interlace {video.interlaced}" if video.interlaced and video.interlaced != "False" else ""),
("--vpp-yadif" if video.video_settings.deinterlace else ""),
(f"--vpp-colorspace hdr2sdr=mobius" if video.video_settings.remove_hdr else ""),
remove_hdr,
Expand Down
13 changes: 13 additions & 0 deletions fastflix/encoders/vceencc_hevc/settings_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def __init__(self, parent, main, app: FastFlixApp):
qp_line.addStretch(1)
qp_line.addLayout(self.init_level())
qp_line.addStretch(1)
qp_line.addLayout(self.init_decoder())
qp_line.addStretch(1)
qp_line.addLayout(self.init_metrics())
grid.addLayout(qp_line, 5, 0, 1, 6)

Expand Down Expand Up @@ -220,6 +222,16 @@ def init_ref(self):
min_width=60,
)

def init_decoder(self):
return self._add_combo_box(
widget_name="decoder",
label="Decoder",
options=["Hardware", "Software"],
opt="decoder",
tooltip="Hardware: use libavformat + hardware decoder for input\nSoftware: use avcodec + software decoder",
min_width=80,
)

def init_metrics(self):
return self._add_check_box(
widget_name="metrics",
Expand Down Expand Up @@ -260,6 +272,7 @@ def update_video_encoder_settings(self):
pre_encode=self.widgets.pre_encode.isChecked(),
pre_analysis=self.widgets.pre_analysis.isChecked(),
vbaq=self.widgets.vbaq.isChecked(),
decoder=self.widgets.decoder.currentText(),
)

encode_type, q_value = self.get_mode_settings()
Expand Down
16 changes: 13 additions & 3 deletions fastflix/flix.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import os
import re
from pathlib import Path
from subprocess import PIPE, CompletedProcess, Popen, TimeoutExpired, run
from subprocess import PIPE, CompletedProcess, Popen, TimeoutExpired, run, check_output
from typing import List, Tuple, Union
from distutils.version import LooseVersion

import reusables
from box import Box, BoxError
Expand Down Expand Up @@ -440,11 +441,16 @@ def detect_hdr10_plus(app: FastFlixApp, config: Config, **_):

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 {hdr10_parser_version}")

for stream in app.fastflix.current_video.streams.video:
logger.debug(f"Checking for hdr10+ in stream {stream.index}")
process = Popen(
[
config.ffmpeg,
str(config.ffmpeg),
"-y",
"-i",
clean_file_string(app.fastflix.current_video.source),
Expand All @@ -465,8 +471,12 @@ def detect_hdr10_plus(app: FastFlixApp, config: Config, **_):
stdin=PIPE, # FFmpeg can try to read stdin and wrecks havoc
)

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

process_two = Popen(
[config.hdr10plus_parser, "--verify", "-"],
hdr10_parser_command,
stdout=PIPE,
stderr=PIPE,
stdin=process.stdout,
Expand Down
5 changes: 3 additions & 2 deletions fastflix/models/encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,12 @@ class NVEncCAVCSettings(EncoderSettings):
ref: Optional[str] = None
metrics: bool = False
b_frames: Optional[str] = None
b_ref_mode: str = "disabled"
b_ref_mode: str = "Hardware"


class VCEEncCSettings(EncoderSettings):
name = "HEVC (VCEEncC)"
preset: str = "slow"
profile: str = "main"
bitrate: Optional[str] = "5000k"
cqp: Optional[str] = None
tier: str = "high"
Expand All @@ -178,6 +177,7 @@ class VCEEncCSettings(EncoderSettings):
pre_encode: bool = False
pre_analysis: bool = False
vbaq: bool = False
decoder: str = "Hardware"


class VCEEncCAVCSettings(EncoderSettings):
Expand All @@ -198,6 +198,7 @@ class VCEEncCAVCSettings(EncoderSettings):
pre_encode: bool = False
pre_analysis: bool = False
vbaq: bool = False
decoder: str = "Hardware"


class rav1eSettings(EncoderSettings):
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.3.0"
__version__ = "4.3.1"
__author__ = "Chris Griffith"
52 changes: 35 additions & 17 deletions fastflix/widgets/background_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# -*- coding: utf-8 -*-
import logging
from pathlib import Path
from subprocess import PIPE, STDOUT, Popen, run
from subprocess import PIPE, STDOUT, Popen, run, check_output
from distutils.version import LooseVersion

from qtpy import QtCore

Expand Down Expand Up @@ -110,29 +111,46 @@ def run(self):

self.ffmpeg_signal.emit("Extracting HDR10+ metadata")

hdr10_parser_version_output = check_output(
[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)
self.main.thread_logging_signal.emit(f"Using HDR10 parser version {hdr10_parser_version}")

ffmpeg_command = [
str(self.app.fastflix.config.ffmpeg),
"-y",
"-i",
clean_file_string(self.app.fastflix.current_video.source),
"-map",
f"0:{track}",
"-c:v",
"copy",
"-vbsf",
"hevc_mp4toannexb",
"-f",
"hevc",
"-",
]

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

self.main.thread_logging_signal.emit(
f"Running command: {' '.join(ffmpeg_command)} | {' '.join(hdr10_parser_command)}"
)

process = Popen(
[
self.app.fastflix.config.ffmpeg,
"-y",
"-i",
clean_file_string(self.app.fastflix.current_video.source),
"-map",
f"0:{track}",
"-c:v",
"copy",
"-vbsf",
"hevc_mp4toannexb",
"-f",
"hevc",
"-",
],
ffmpeg_command,
stdout=PIPE,
stderr=open(self.app.fastflix.current_video.work_path / "hdr10extract_out.txt", "wb"),
# stdin=PIPE, # FFmpeg can try to read stdin and wrecks havoc
)

process_two = Popen(
[self.app.fastflix.config.hdr10plus_parser, "-o", clean_file_string(output), "-"],
hdr10_parser_command,
stdout=PIPE,
stderr=PIPE,
stdin=process.stdout,
Expand Down

0 comments on commit 84b337f

Please sign in to comment.