simplify startup setup

This commit is contained in:
Zen 2021-07-08 06:26:17 +03:00
parent 0bd3fa0265
commit 8e8f3a536e
3 changed files with 68 additions and 79 deletions

View file

@ -168,37 +168,3 @@ class Project(object):
log(f"Vapoursynth not installed but vspipe reachable")
log(f"Error: {e}" + "Fallback to Hybrid")
self.chunk_method = "hybrid"
def check_exes(self):
if not find_executable("ffmpeg"):
print("No ffmpeg")
sys.exit(1)
else:
log(get_ffmpeg_info())
if self.chunk_method in ["vs_ffms2", "vs_lsmash"]:
if not find_executable("vspipe"):
print("vspipe executable not found")
sys.exit(1)
try:
import vapoursynth
plugins = vapoursynth.get_core().get_plugins()
if (
self.chunk_method == "vs_lsmash"
and "systems.innocent.lsmas" not in plugins
):
print("lsmas is not installed")
sys.exit(1)
if (
self.chunk_method == "vs_ffms2"
and "com.vapoursynth.ffms2" not in plugins
):
print("ffms2 is not installed")
sys.exit(1)
except ModuleNotFoundError:
print("Vapoursynth is not installed")
sys.exit(1)

View file

@ -15,50 +15,11 @@ from av1an_pyo3 import (
get_default_arguments,
get_default_cq_range,
get_default_pass,
get_ffmpeg_info,
log,
)
def set_target_quality(project):
if project.vmaf_path:
if not Path(project.vmaf_path).exists():
print(f"No model with this path: {Path(project.vmaf_path).as_posix()}")
sys.exit(1)
if project.probes < 4:
print(
"Target quality with less than 4 probes is experimental and not recommended"
)
# setting range for q values
if project.min_q is None:
project.min_q, _ = get_default_cq_range(project.encoder)
assert project.min_q > 1
if project.max_q is None:
_, project.max_q = get_default_cq_range(project.encoder)
def setup_encoder(project: Project):
settings_valid = find_executable(encoder_bin(project.encoder))
if not settings_valid:
print(
f"Encoder {encoder_bin(project.encoder)} not found. Is it installed in the system path?"
)
sys.exit(1)
if project.passes is None:
project.passes = get_default_pass(project.encoder)
project.video_params = (
get_default_arguments(project.encoder)
if project.video_params is None
else shlex.split(project.video_params)
)
validate_inputs(project)
def startup_check(project: Project):
if sys.version_info < (3, 6):
print("Python 3.6+ required")
@ -82,12 +43,75 @@ def startup_check(project: Project):
if project.is_vs:
project.chunk_method = "vs_ffms2"
project.check_exes()
if not find_executable("ffmpeg"):
print("No ffmpeg")
sys.exit(1)
else:
log(get_ffmpeg_info())
set_target_quality(project)
if project.chunk_method in ["vs_ffms2", "vs_lsmash"]:
if not find_executable("vspipe"):
print("vspipe executable not found")
sys.exit(1)
setup_encoder(project)
try:
import vapoursynth
plugins = vapoursynth.get_core().get_plugins()
if (
project.chunk_method == "vs_lsmash"
and "systems.innocent.lsmas" not in plugins
):
print("lsmas is not installed")
sys.exit(1)
if (
project.chunk_method == "vs_ffms2"
and "com.vapoursynth.ffms2" not in plugins
):
print("ffms2 is not installed")
sys.exit(1)
except ModuleNotFoundError:
print("Vapoursynth is not installed")
sys.exit(1)
if project.vmaf_path:
if not Path(project.vmaf_path).exists():
print(f"No model with this path: {Path(project.vmaf_path).as_posix()}")
sys.exit(1)
if project.probes < 4:
print(
"Target quality with less than 4 probes is experimental and not recommended"
)
# setting range for q values
if project.min_q is None:
project.min_q, _ = get_default_cq_range(project.encoder)
assert project.min_q > 1
if project.max_q is None:
_, project.max_q = get_default_cq_range(project.encoder)
settings_valid = find_executable(encoder_bin(project.encoder))
if not settings_valid:
print(
f"Encoder {encoder_bin(project.encoder)} not found. Is it installed in the system path?"
)
sys.exit(1)
if project.passes is None:
project.passes = get_default_pass(project.encoder)
project.video_params = (
get_default_arguments(project.encoder)
if project.video_params is None
else shlex.split(project.video_params)
)
validate_inputs(project)
project.audio_params = shlex.split(project.audio_params)
project.ffmpeg = shlex.split(project.ffmpeg)

View file

@ -22,7 +22,6 @@ REQUIRES = [
"opencv-python",
"psutil",
"scipy",
"matplotlib",
"maturin",
"setuptools_rust",
]