From fa5dd4dbe14ad6b59357ff6c95b3e176770d17e5 Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 7 Jan 2022 00:49:00 -0500 Subject: [PATCH 1/3] Fix multisegment import not working properly with new SD format --- encode.avs | 4 ++-- programs/functions.avsi | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/encode.avs b/encode.avs index fb6307d..4b807f8 100644 --- a/encode.avs +++ b/encode.avs @@ -126,7 +126,7 @@ file = hd \ : "logo.png" # file = !hd ? "logo34.png" : "hdlogo34.png" -prescaleFactor > 1 ? \ +prescaleFactor > 1 && !hd ? \ PointResize(last.width * prescaleFactor, last.height * prescaleFactor) : 0 # Aspect ratio correction for SD encodes @@ -164,7 +164,7 @@ resized = hd \ : Lanczos4Resize(width, height) # If ms enabled, we use parameters of "resized" to apply to all segments -resized = ms ? resized.AppendSegment(ms_base, ms_start, ms_end, ms_format, resizer, pixelType).ConvertToRGB32() : resized +resized = ms ? resized.AppendSegment(ms_base, ms_start, ms_end, ms_format, resizer, hd, pixelType).ConvertToRGB32() : resized # Logo logoVideo = ImageSource(file=file, start=0, end=int((resized.FrameRate * 2) - 1), fps=resized.FrameRate) \ diff --git a/programs/functions.avsi b/programs/functions.avsi index 4b95f11..3baf866 100644 --- a/programs/functions.avsi +++ b/programs/functions.avsi @@ -6,12 +6,22 @@ function AppendSegment( \ int last_val, \ string format, \ string resizer, +\ bool hd, \ string pix_type \){ filename = base + string(first_val, format) + ".avi" - result = AviSource(filename, pixel_type=pix_type).Eval(resizer + """Resize(sample.width, sample.height)""") + result = AviSource(filename, pixel_type=pix_type) + + if (hd) { + result = result.Eval(resizer + """Resize(sample.width, sample.height)""") + } else { + scaler = sample.height / result.height + temp_width = result.width * scaler + result = result.PointResize(temp_width, sample.height) + result = result.Lanczos4Resize(sample.width, sample.height) + } return (first_val < last_val) \ - ? result + sample.AppendSegment(base, first_val+1, last_val, format, resizer, pix_type) \ + ? result + sample.AppendSegment(base, first_val+1, last_val, format, resizer, hd, pix_type) \ : result } From cb520c36cc80e980a9d54b598514634ee21dbbc9 Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 7 Jan 2022 14:49:03 -0500 Subject: [PATCH 2/3] Change the recursion loop into a for loop --- programs/functions.avsi | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/programs/functions.avsi b/programs/functions.avsi index 3baf866..38fcbe0 100644 --- a/programs/functions.avsi +++ b/programs/functions.avsi @@ -20,9 +20,24 @@ function AppendSegment( result = result.PointResize(temp_width, sample.height) result = result.Lanczos4Resize(sample.width, sample.height) } - return (first_val < last_val) \ - ? result + sample.AppendSegment(base, first_val+1, last_val, format, resizer, hd, pix_type) \ - : result + + for (i = first_val + 1, last_val) { + filename = base + string(i, format) + ".avi" + next_clip = AviSource(filename, pixel_type=pix_type) + + if (hd) { + next_clip = next_clip.Eval(resizer + """Resize(sample.width, sample.height)""") + } else { + scaler = sample.height / next_clip.height + temp_width = next_clip.width * scaler + next_clip = next_clip.PointResize(temp_width, sample.height) + next_clip = next_clip.Lanczos4Resize(sample.width, sample.height) + } + + result = result + next_clip + } + + return result } function Remove( From bbf82b61b9fda5079380f3f6e232f284bed9d2d6 Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 7 Jan 2022 16:30:17 -0500 Subject: [PATCH 3/3] Make sure this variable is an int here temp_width can be a float. --- programs/functions.avsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/functions.avsi b/programs/functions.avsi index 38fcbe0..709c271 100644 --- a/programs/functions.avsi +++ b/programs/functions.avsi @@ -17,7 +17,7 @@ function AppendSegment( } else { scaler = sample.height / result.height temp_width = result.width * scaler - result = result.PointResize(temp_width, sample.height) + result = result.PointResize(int(temp_width), sample.height) result = result.Lanczos4Resize(sample.width, sample.height) } @@ -30,7 +30,7 @@ function AppendSegment( } else { scaler = sample.height / next_clip.height temp_width = next_clip.width * scaler - next_clip = next_clip.PointResize(temp_width, sample.height) + next_clip = next_clip.PointResize(int(temp_width), sample.height) next_clip = next_clip.Lanczos4Resize(sample.width, sample.height) }