Compare commits

..

2 Commits

Author SHA1 Message Date
e5b2043298 Add ssim filter 2022-10-24 12:48:20 +02:00
d3753ac831 WIP Add psnr function 2022-10-24 12:41:45 +02:00

View File

@ -148,7 +148,7 @@ def encode_libaom(inputfile: str, outputfile: str, crf: int, preset: Union[str,
def score_vmaf(outputfile: str, inputfile: str) -> dict[str, float]:
"""
Calculate a file's VMAF score
Calculate a file's VMAF score. Higher is better
Parameters:
outputfile (str): Path to output file
@ -179,6 +179,48 @@ def score_vmaf(outputfile: str, inputfile: str) -> dict[str, float]:
return vmaf
def score_psnr(outputfile: str, inputfile: str):
"""
Calculate a file's MSE (mean-square error) using PSNR. A lower value is better
Parameters:
outputfile (str): Path to output file
inputfile (str): Path to input file
Return:
TBD
"""
ff = ffmpy.FFmpeg(
inputs=OrderedDict([(outputfile, None), (inputfile, None)]),
outputs={"-": "-lavfi psnr=stats_file=psnr.log -f null"},
)
ff.run()
# Steps to get mse value
def score_ssim(outputfile: str, inputfile: str):
"""
Calculate a file's SSIM rating. TBD
Parameters:
outputfile (str): Path to output file
inputfile (str): Path to input file
Return:
TBD
"""
ff = ffmpy.FFmpeg(
inputs=OrderedDict([(outputfile, None), (inputfile, None)]),
outputs={"-": "-lavfi ssim=stats_file=ssim.log -f null"},
)
ff.run()
# Steps to get ssim value
if __name__ == "__main__":
if not os.path.isdir("encoded"):
os.mkdir("encoded")