import subprocess
import sys
from pathlib import Path
import os
import re

#output_folder_name ="/bulk_convert_out/"

ref_video=input("reference video: ")
dist_video=input("distorted video: ")

#droppedFile = sys.argv[1]
#droppedName = Path(droppedFile).name
#originalfiles = sys.orig_argv[2:]

#long path shenanigans 
#joined = (' '.join(originalfiles))
#re.sub (' +', ' ', joined)
#listed = re.split(r'(.+?mkv|.+?mov|.+?mp4)', joined)
#listed = list(filter(None, listed))
#listed = [i.lstrip() for i in listed]

#print(droppedName)

#get path of script location and remove the tail
#head_tail = os.path.split(sys.argv[0])
#output_path = head_tail[0]
#from_time = input("start point (second)")
#to_time = input("end point (second)")

#skip first part of sys.argv since it points to script location
#arguments = sys.argv[1:]

#check if output folder exists, otherwise create it
#isExist = os.path.exists(output_path+output_folder_name)
#if not isExist:
#    os.makedirs(output_path+output_folder_name)


#for file in listed:
#splitter = os.path.split(file)
#file_folder = splitter[0]
basename = os.path.basename(dist_video)
#print(file)
args = '.\\ffmpeg.exe -i {ref_video} -i {dist_video} -filter_complex "[0:v]scale=1920x1080:flags=bicubic[main];[1:v]scale=1920x1080:flags=bicubic[ref];[main][ref]libvmaf=feature=name=psnr|name=float_ssim:log_path=vmaf.log:n_threads=20" -f null -'.format(ref_video=ref_video, dist_video=dist_video)
print(args)
subprocess.run(args)


k=input("press close to exit") 