Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
24th July 2015, 02:20 | #1 | Link |
Registered User
Join Date: Jul 2015
Location: Canada
Posts: 5
|
Vapoursynth AddBorders with StaxRip
I’m familiar with the Avisynth function (script?) “AddBorders(0, 86, 0, 86, $000000)”. Using this in Vapoursynth creates a Python error, saying there’s an invalid syntax. Understandably you may say.
Vapoursynth docs indicates the Avisynth equivalent as “std.AddBorders” or “std.AddBorders(clip clip[, int left=0, int right=0, int top=0, int bottom=0, float[] color=<black>])”. My feeble attempts have not resulted in a positive. Not understanding how to write this properly, I have to ask if someone would kindly help. |
24th July 2015, 02:58 | #2 | Link |
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,666
|
Here's an example on how to use AddBorders:
Code:
import vapoursynth as vs core = vs.get_core() src = core.std.BlankClip(color=[255, 255, 255]) src = core.std.AddBorders(clip=src, left=0, right=0, top=86, bottom=86, color=[0, 0, 0]) src.set_output() |
24th July 2015, 04:54 | #3 | Link |
Registered User
Join Date: Jul 2015
Location: Canada
Posts: 5
|
Thanks for your assistance.
Adjusted top and bottom numbers and loaded your code into StaxRip’s Scripting Editor, and got the following error: Python exception: name 'core' is not defined Traceback (most recent call last): File "vapoursynth.pyx", line 1467, in vapoursynth.vpy_evaluateScript (src\cython\vapoursynth.c:24719) File "N:\Rips\TS00852\TS00852 temp files\TS00852_new.vpy", line 1, in <module> core.std.LoadPlugin(r'N:\Portable\StaxRip\Apps\Plugins\both\ffms2\ffms2.dll') NameError: name 'core' is not defined Any ideas? |
24th July 2015, 09:57 | #5 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
you have to use clip instead of src, I might be able to remove this restriction, profiles use clip and core as variable names.
Code:
clip = core.std.AddBorders(clip = clip, left = 0, right = 0, top = 86, bottom = 86, color = [0, 0, 0]) Code:
[Borders] AddBorder1080 = w = (1920 - width) / 2.0 h = (1080 - height) / 2.0 AddBorders(floor(w), floor(h), ceil(w), ceil(h))
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
24th July 2015, 23:33 | #6 | Link |
Registered User
Join Date: Oct 2010
Posts: 36
|
Technically not 100% true, Python supports 0x hex notation and will automatically convert it into decimal, so: [0xFF, 0xFF, 0xFF] is the same as [255, 255, 255] so if you're converting Avisynth scripts you don't have to do the hex conversion.
It's also good to note that the color parameter replaces both color and color_yuv in blank clip in Avisynth. Vapoursynth will use the RGB if the format is an RGB format, YUV if it is a YUV format, and Grey if it is a single channel clip. The other thing to be aware of is the color number is also related to the bit depth of the clip, so 8bit clips will have 255 as white (or 235 for limited range), 10bit clips white is 1023, 16bit clips is 65535 and 1.0 for float. So if dealing with high bit depth clips using 8 bit colors will not work and will need to be converted to the correct format. This information is lacking in the documentation, and should be added. |
25th July 2015, 01:24 | #8 | Link |
Registered User
Join Date: Jul 2015
Location: Canada
Posts: 5
|
Thanks Stax76, your code worked beautifully and seems more straight forward (in my mind). Is it specific to StaxRip?
I know there seems to be more interest in cropping than adding borders. Have you considered adding a Border Menu alongside Aspect Ratio and Crop within Image Options? Thank you so much for helping and for everyone’s patience with a non-coder. |
25th July 2015, 17:41 | #11 | Link | |
Registered User
Join Date: Jul 2015
Location: Canada
Posts: 5
|
Quote:
When using the Avisynth code, $000000 is black and I get black. |
|
25th July 2015, 17:51 | #12 | Link | |
Registered User
Join Date: Oct 2010
Posts: 36
|
Quote:
color defaults to black if it isn't set, but for YUV it should be: [0, 128, 128] |
|
26th July 2015, 19:16 | #15 | Link | |
Registered User
Join Date: Oct 2010
Posts: 36
|
Quote:
EDIT: Actually no my mistake, Integer YUV types are shifted by (2^bitdepth)/2 to make all the numbers positive. Last edited by splinter98; 26th July 2015 at 19:29. Reason: Correct my previous error |
|
Tags |
addborders, vapoursynth |
Thread Tools | Search this Thread |
Display Modes | |
|
|