From a63fc8786f7ba2959ccf05642597c350a8e919ba Mon Sep 17 00:00:00 2001 From: Zen <46526140+master-of-zen@users.noreply.github.com> Date: Tue, 21 Jul 2020 20:42:15 +0300 Subject: [PATCH] moved utils to Av1an + refactoring --- {utils => Av1an}/__init__.py | 0 {utils => Av1an}/aom_kf.py | 0 {utils => Av1an}/arg_parse.py | 0 {utils => Av1an}/bar.py | 0 {utils => Av1an}/boost.py | 2 +- {utils => Av1an}/compose.py | 2 +- {utils => Av1an}/config.py | 3 --- {utils => Av1an}/encode.py | 0 {utils => Av1an}/ffmpeg.py | 0 {utils => Av1an}/fp_reuse.py | 0 {utils => Av1an}/job.py | 0 {utils => Av1an}/logger.py | 0 {utils => Av1an}/pyscene.py | 0 {utils => Av1an}/setup.py | 0 {utils => Av1an}/split.py | 3 +-- {utils => Av1an}/target_vmaf.py | 8 ++++---- {utils => Av1an}/utils.py | 2 -- {utils => Av1an}/vmaf.py | 4 ++-- av1an.py | 10 +--------- 19 files changed, 10 insertions(+), 24 deletions(-) rename {utils => Av1an}/__init__.py (100%) rename {utils => Av1an}/aom_kf.py (100%) rename {utils => Av1an}/arg_parse.py (100%) rename {utils => Av1an}/bar.py (100%) rename {utils => Av1an}/boost.py (96%) rename {utils => Av1an}/compose.py (99%) rename {utils => Av1an}/config.py (88%) rename {utils => Av1an}/encode.py (100%) rename {utils => Av1an}/ffmpeg.py (100%) rename {utils => Av1an}/fp_reuse.py (100%) rename {utils => Av1an}/job.py (100%) rename {utils => Av1an}/logger.py (100%) rename {utils => Av1an}/pyscene.py (100%) rename {utils => Av1an}/setup.py (100%) rename {utils => Av1an}/split.py (98%) rename {utils => Av1an}/target_vmaf.py (96%) rename {utils => Av1an}/utils.py (99%) rename {utils => Av1an}/vmaf.py (96%) diff --git a/utils/__init__.py b/Av1an/__init__.py similarity index 100% rename from utils/__init__.py rename to Av1an/__init__.py diff --git a/utils/aom_kf.py b/Av1an/aom_kf.py similarity index 100% rename from utils/aom_kf.py rename to Av1an/aom_kf.py diff --git a/utils/arg_parse.py b/Av1an/arg_parse.py similarity index 100% rename from utils/arg_parse.py rename to Av1an/arg_parse.py diff --git a/utils/bar.py b/Av1an/bar.py similarity index 100% rename from utils/bar.py rename to Av1an/bar.py diff --git a/utils/boost.py b/Av1an/boost.py similarity index 96% rename from utils/boost.py rename to Av1an/boost.py index dbf7ef5..62464c1 100755 --- a/utils/boost.py +++ b/Av1an/boost.py @@ -2,7 +2,7 @@ import sys -from utils.utils import get_brightness, get_cq, man_q +from .utils import get_brightness, get_cq, man_q from .logger import log diff --git a/utils/compose.py b/Av1an/compose.py similarity index 99% rename from utils/compose.py rename to Av1an/compose.py index c82b21e..7a6e7d2 100755 --- a/utils/compose.py +++ b/Av1an/compose.py @@ -5,7 +5,7 @@ import os import sys from pathlib import Path -from utils.utils import terminate +from .utils import terminate from .logger import log diff --git a/utils/config.py b/Av1an/config.py similarity index 88% rename from utils/config.py rename to Av1an/config.py index deee244..b96a5a6 100644 --- a/utils/config.py +++ b/Av1an/config.py @@ -1,8 +1,5 @@ #!/usr/bin/env python3 import json -from pathlib import Path -from .utils import terminate -from .compose import get_default_params_for_encoder def conf(args): """Creation and reading of config files with saved settings""" diff --git a/utils/encode.py b/Av1an/encode.py similarity index 100% rename from utils/encode.py rename to Av1an/encode.py diff --git a/utils/ffmpeg.py b/Av1an/ffmpeg.py similarity index 100% rename from utils/ffmpeg.py rename to Av1an/ffmpeg.py diff --git a/utils/fp_reuse.py b/Av1an/fp_reuse.py similarity index 100% rename from utils/fp_reuse.py rename to Av1an/fp_reuse.py diff --git a/utils/job.py b/Av1an/job.py similarity index 100% rename from utils/job.py rename to Av1an/job.py diff --git a/utils/logger.py b/Av1an/logger.py similarity index 100% rename from utils/logger.py rename to Av1an/logger.py diff --git a/utils/pyscene.py b/Av1an/pyscene.py similarity index 100% rename from utils/pyscene.py rename to Av1an/pyscene.py diff --git a/utils/setup.py b/Av1an/setup.py similarity index 100% rename from utils/setup.py rename to Av1an/setup.py diff --git a/utils/split.py b/Av1an/split.py similarity index 98% rename from utils/split.py rename to Av1an/split.py index 7fd595c..c81cc61 100755 --- a/utils/split.py +++ b/Av1an/split.py @@ -7,8 +7,7 @@ from ast import literal_eval from pathlib import Path from subprocess import PIPE, STDOUT -from utils.utils import frame_probe, get_keyframes - +from .utils import frame_probe, get_keyframes from .aom_kf import aom_keyframes from .logger import log from .pyscene import pyscene diff --git a/utils/target_vmaf.py b/Av1an/target_vmaf.py similarity index 96% rename from utils/target_vmaf.py rename to Av1an/target_vmaf.py index 3fbcf9a..501f096 100644 --- a/utils/target_vmaf.py +++ b/Av1an/target_vmaf.py @@ -1,12 +1,12 @@ #!/bin/env python -from utils.utils import terminate, frame_probe -from utils.vmaf import call_vmaf, read_vmaf_xml +from .utils import terminate, frame_probe +from .vmaf import call_vmaf, read_vmaf_xml from scipy import interpolate from pathlib import Path import subprocess import numpy as np -from utils.logger import log +from .logger import log from matplotlib import pyplot as plt import matplotlib import sys @@ -103,7 +103,7 @@ def target_vmaf(source, args): cmd = probe_cmd(probe, fork[i], args.ffmpeg_pipe, args.encoder) subprocess.run(cmd, shell=True) - v = call_vmaf(probe, gen_probes_names(probe, fork[i]), n_threads=args.n_threads, model=args.vmaf_path, return_file=True) + v = call_vmaf(probe, gen_probes_names(probe, fork[i]), args.n_threads, args.vmaf_path, return_file=True) mean = read_vmaf_xml(v, 25) vmaf_cq.append((mean, fork[i])) diff --git a/utils/utils.py b/Av1an/utils.py similarity index 99% rename from utils/utils.py rename to Av1an/utils.py index 58b0731..0b106f3 100755 --- a/utils/utils.py +++ b/Av1an/utils.py @@ -1,8 +1,6 @@ #!/bin/env python -import atexit import json -import os import re import statistics import subprocess diff --git a/utils/vmaf.py b/Av1an/vmaf.py similarity index 96% rename from utils/vmaf.py rename to Av1an/vmaf.py index 22e237e..05e8cd3 100755 --- a/utils/vmaf.py +++ b/Av1an/vmaf.py @@ -28,7 +28,7 @@ def read_vmaf_xml(file, percentile): return perc -def call_vmaf(source: Path, encoded: Path, model, n_threads, return_file=False): +def call_vmaf(source: Path, encoded: Path, n_threads, model, return_file=False): if model: mod = f":model_path={model}" @@ -72,7 +72,7 @@ def plot_vmaf(inp: Path, out: Path, model=None): print('Calculating Vmaf...\r', end='') - xml = call_vmaf(inp, out, n_threads=0, model=model, return_file=True) + xml = call_vmaf(inp, out, 0, model, return_file=True) if not Path(xml).exists(): print(f'Vmaf calculation failed for files:\n {inp.stem} {out.stem}') diff --git a/av1an.py b/av1an.py index bb3453d..e6a7f12 100755 --- a/av1an.py +++ b/av1an.py @@ -1,14 +1,6 @@ #!/usr/bin/env python3 - -import shutil -import subprocess -import sys -import time -from pathlib import Path -import json - -from utils import * +from Av1an import * class Av1an: