From 679e8d2de18677012fbc967ac1a9eeb3ccf71365 Mon Sep 17 00:00:00 2001 From: Vash Patel Date: Sun, 5 May 2019 15:03:11 -0400 Subject: [PATCH] Changed calculation of filter_threshold so thresholds >100 don't error Since it's not always necessary that resulting transcode have a smaller size, changed the way this function works so you can set threshold higher than 100%. Previously, putting something like 150% would result in early termination of the transcode because it required the new file to be smaller than the old file. --- pytranscoder/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytranscoder/utils.py b/pytranscoder/utils.py index bd92bf2..191b065 100644 --- a/pytranscoder/utils.py +++ b/pytranscoder/utils.py @@ -14,8 +14,8 @@ def filter_threshold(profile: Profile, inpath, outpath): pct_threshold = profile.threshold orig_size = os.path.getsize(inpath) new_size = os.path.getsize(outpath) - pct_savings = 100 - math.floor((new_size * 100) / orig_size) - if pct_savings < pct_threshold: + size_threshold = pct_threshold * orig_size + if new_size > size_threshold: return False return True