Compare commits
No commits in common. "b1aa5ba9bc522fe1b077cce65418d659fb1eae87" and "8584ff911ef2be80200d318e013238280720994b" have entirely different histories.
b1aa5ba9bc
...
8584ff911e
@ -8,8 +8,6 @@ import csv
|
|||||||
|
|
||||||
import ffmpy
|
import ffmpy
|
||||||
|
|
||||||
import argparse
|
|
||||||
|
|
||||||
from multiprocessing import cpu_count
|
from multiprocessing import cpu_count
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
@ -59,34 +57,6 @@ def now():
|
|||||||
return int(time.time())
|
return int(time.time())
|
||||||
|
|
||||||
|
|
||||||
def cleanup(keepencodes: bool, outputfile: str = ""):
|
|
||||||
"""
|
|
||||||
Clean up files on program exit/interruption
|
|
||||||
"""
|
|
||||||
|
|
||||||
try:
|
|
||||||
# REVIEW make removal optional/togglable with cli switch
|
|
||||||
if not keepencodes:
|
|
||||||
os.remove(outputfile)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.remove("vmaf.json")
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.remove("ssim.log")
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.remove("psnr.log")
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def write_line(
|
def write_line(
|
||||||
datafile: str,
|
datafile: str,
|
||||||
codec: str,
|
codec: str,
|
||||||
@ -297,7 +267,7 @@ def score_psnr(outputfile: str, inputfile: str) -> float:
|
|||||||
return mse_avg
|
return mse_avg
|
||||||
|
|
||||||
|
|
||||||
def main(inputfile: str, outputpath: str = "encodes", keepencodes: bool = False):
|
def main(inputfile: str, outputpath: str = "encodes"):
|
||||||
"""
|
"""
|
||||||
Main program function so this program can be used from the command line or as a library import.
|
Main program function so this program can be used from the command line or as a library import.
|
||||||
|
|
||||||
@ -394,57 +364,17 @@ def main(inputfile: str, outputpath: str = "encodes", keepencodes: bool = False)
|
|||||||
mse=mse,
|
mse=mse,
|
||||||
)
|
)
|
||||||
|
|
||||||
cleanup(keepencodes=keepencodes, outputfile=outputfile)
|
# TODO make removal optional/togglable with cli switch
|
||||||
|
os.remove(outputfile)
|
||||||
|
|
||||||
|
os.remove("vmaf.json")
|
||||||
|
os.remove("ssim.log")
|
||||||
|
os.remove("psnr.log")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(description="")
|
# TODO expose this as variable/argument?
|
||||||
|
outputpath: str = ""
|
||||||
|
inputfile: str = "source/Sparks_in_Blender.webm"
|
||||||
|
|
||||||
parser.add_argument(
|
main(inputfile=inputfile)
|
||||||
"-o",
|
|
||||||
"--output-dir",
|
|
||||||
required=False,
|
|
||||||
type=str,
|
|
||||||
help='Output directory for encodes. Default is "encodes" in current working directory',
|
|
||||||
default="encodes",
|
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_argument(
|
|
||||||
"-i",
|
|
||||||
"--input-file",
|
|
||||||
required=True,
|
|
||||||
type=str,
|
|
||||||
help="Input file to encode",
|
|
||||||
)
|
|
||||||
|
|
||||||
# in case you wanted to rerun the conversion for everything
|
|
||||||
parser.add_argument(
|
|
||||||
"-r",
|
|
||||||
"--reset",
|
|
||||||
required=False,
|
|
||||||
action="store_true",
|
|
||||||
help="Rerun conversion for all files",
|
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_argument(
|
|
||||||
"-k",
|
|
||||||
"--keep-encodes",
|
|
||||||
action="store_true",
|
|
||||||
required=False,
|
|
||||||
help="Don't delete encodes after getting their scores. Default is delete (False)",
|
|
||||||
)
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
# REVIEW expose this as variable/argument?
|
|
||||||
outputpath: str = args.output_dir
|
|
||||||
inputfile: str = args.input_file
|
|
||||||
|
|
||||||
keepencodes: bool = args.keep_encodes
|
|
||||||
|
|
||||||
# main program loop with cleanup in case of interrupt
|
|
||||||
try:
|
|
||||||
main(inputfile=inputfile, outputpath=outputpath, keepencodes=keepencodes)
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
# run cleanup function on keyboard interrupt
|
|
||||||
cleanup(keepencodes=keepencodes)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user