Skip to content

Commit 258ad90

Browse files
some systems need segments to be letterboxed to some overarching res (#22)
* some systems need segments to be letterboxed to some overarching res (wonderswan) - target resolution is deduced automatically by looking at all segments - since we can letterbox at native res during initial import, resizing is not involved - resize based MS import is incompatible with this setting * - drop the sample arg since it's not used - movie the option around for more clarity - set msAudioFile path when there's external audio to import, instead of having both path and bool switch - allow using external audio for msLetterbox
1 parent ed04992 commit 258ad90

File tree

2 files changed

+52
-7
lines changed

2 files changed

+52
-7
lines changed

encode.avs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,13 @@ subSizepc = 5 # subtitles font size in percents of smaller video side
5151
# Multisegment import (upscales hires segments straight to HD when needed)
5252
# requires normally importing a sample whose attributes it will use for all segments
5353
ms = false # enable multisegment import
54+
msLetterbox = false # import segments with letterboxing instead of resizing
55+
# (initally imported clip is discarded)
5456
msBase = "movie_" # common string for all segment names
55-
msStart = 0 # number of the first segment
57+
msStart = 0 # number of the first segment
5658
msEnd = 15 # number of the last segment
5759
msFormat = "%1.0f" # string format: http://avisynth.nl/index.php/Internal_functions#String
58-
msAudio = false # use separate audio file for video
59-
msAudiotrack = "PSXjin.wav" # path to audio file
60+
msAudioFile = "" # path to external audio file. not used when empty
6061

6162
# Aspect ratio correction
6263
wAspect = 4
@@ -109,6 +110,14 @@ audio = \
109110
# AUTOMATED SETTINGS #
110111
######################
111112

113+
if (msLetterbox) {
114+
AppendSegmentLetterbox(msBase, msStart, msEnd, msFormat, pixelType)
115+
116+
if (msAudioFile != "") {
117+
AudioDub(last, WavSource(msAudioFile))
118+
}
119+
}
120+
112121
ConvertToRGB32()
113122

114123
# Add 1 scanline if height is uneven (ntsc sms, pal c64)
@@ -187,13 +196,13 @@ resized = hd || ARCorrection \
187196
: last
188197

189198
# If ms enabled, we use parameters of "resized" to apply to all segments
190-
if (ms) {
199+
if (ms && !msLetterbox) {
191200
resized = resized \
192201
.AppendSegment(msBase, msStart, msEnd, msFormat, resizer, hd, pixelType) \
193202
.ConvertToRGB32()
194203

195-
if (msAudio) {
196-
resized = AudioDub(resized, WavSource(msAudiotrack))
204+
if (msAudioFile != "") {
205+
resized = AudioDub(resized, WavSource(msAudioFile))
197206
}
198207
}
199208

programs/functions.avsi

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Multisegment AVI import
1+
# Multisegment AVI import via resizing
22
function AppendSegment(
33
\ clip sample,
44
\ string base,
@@ -32,6 +32,42 @@ function AppendSegment(
3232
return result
3333
}
3434

35+
# Multisegment AVI import via letterboxing
36+
function AppendSegmentLetterbox(
37+
\ string base,
38+
\ int first_val,
39+
\ int last_val,
40+
\ string format,
41+
\ string pix_type
42+
\){
43+
biggest_width = 0
44+
biggest_height = 0
45+
46+
for (i = first_val, last_val) {
47+
filename = base + string(i, format) + ".avi"
48+
AviSource(filename, pixel_type=pix_type)
49+
biggest_width = biggest_width < last.width ? last.width : biggest_width
50+
biggest_height = biggest_height < last.height ? last.height : biggest_height
51+
}
52+
53+
for (i = first_val, last_val) {
54+
filename = base + string(i, format) + ".avi"
55+
AviSource(filename, pixel_type=pix_type)
56+
57+
xside = int(biggest_width - last.width) / 2
58+
yside = int(biggest_height - last.height) / 2
59+
AddBorders(xside, yside, xside, yside)
60+
61+
if (i == first_val) {
62+
result = last
63+
} else {
64+
result = result + last
65+
}
66+
}
67+
68+
return result
69+
}
70+
3571
# rounds an integer up or down to the nearest multiple of mod
3672
function ForceModulo(
3773
\ int number,

0 commit comments

Comments
 (0)