This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Error in Resize after after Lower Res.
Hello Selur,

   I found a resize problem under specific setting.

   The input movie has resolution 1920x1080
   Since I want apply RealESERGAN to speed up the resize I applied Filtering->Vapoursynth->Misc->Lower res. before resize = 2

    After having applied all the reaming filter settings and save the job, it is displayed the following error

[Image: Error-Resize.jpg]

    The problem is the following:
       1)  the initial size is: 1920x1080
       2)  after the crop of 130 up/down the size is: 1920x820
       3) then after the resize by 2.0, the size is 960x410
       4) Hybrid add a border of 2, so that the size becomes: 960x412
       5) RealESERGAN resize the video to 3840x1648
       6) then Hybrid resize the video to 1920x820
       7) the Hybrid remove 8 pixels from the border
       8) the final size is 1920x812 -> ERROR
       I think the the step 7 should be applied before the step 6, in this way the output size should be correct
       I hope that you will be able to fix this issue


I attached the debug file
Think I fixed this a few days ago.
Using your steps, my dev version ends with 1920x820:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
import ctypes
import os
import site
core = vs.core
# Adding torch dependencies to PATH
path = site.getsitepackages()[0]+'/torch_dependencies/bin/'
path = path.replace('\\', '/')
os.environ["PATH"] = path + os.pathsep + os.environ["PATH"]
# Loading Plugins
# source: 'G:\TestClips&Co\In_America_(2002).mkv'
# current color space: YUV420P8, bit depth: 8, resolution: 1920x1080, fps: 23.976, color matrix: 709, yuv luminance scale: limited, scanorder: progressive
# Loading G:\TestClips&Co\In_America_(2002).mkv using DGSource
clip = core.dgdecodenv.DGSource("J:/tmp/mkv_21c058149c797c35b163bbc419842782_853323747.dgi")# 23.976 fps, scanorder: progressive
# Setting detected color matrix (709).
clip = core.std.SetFrameProps(clip, _Matrix=1)
# Setting color transfer info (709), when it is not set
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=1)
# Setting color primaries info (BT.709), when it is not set
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 23.976
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
clip = core.std.CropRel(clip=clip, left=0, right=0, top=130, bottom=130)# cropping to 1920x820
# adjusting resolution before resizing
clip = core.fmtc.resample(clip=clip, w=960, h=410, kernel="lanczos", interlaced=False, interlacedd=False)# before YUV420P8 after YUV420P16
from vsrealesrgan import realesrgan as RealESRGAN
clip = core.std.AddBorders(clip=clip, left=0, right=0, top=0, bottom=2) # add borders to archive mod 4 (vsRealESRGAN) - 960x412
# adjusting color space from YUV420P16 to RGBS for vsRealESRGAN
clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="709", range_s="limited")
# resizing using RealESRGAN
clip = RealESRGAN(clip=clip, model=5, device_index=0) # 3840x1648
# resizing 3840x1648 to 1920x820
clip = core.std.CropRel(clip=clip, left=0, right=0, top=0, bottom=8) # removing borders (vsRealESRGAN) -  3840x1640
# adjusting resizing
clip = core.fmtc.resample(clip=clip, w=1920, h=820, kernel="spline64", interlaced=False, interlacedd=False)
# adjusting output color from: RGBS to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="709", range_s="limited", dither_type="error_diffusion")
# set output frame rate to 23.976fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
# Output
=> will send you a link to my current dev via pm.

Cu Selur
Hello Selur,

   The problem has been fixed with the last dev version.
   It would be nice to add the option to resize using the mod (2,4,8,16,32) in  Filtering->Vapoursynth->Misc->Lower res. before resize so that the add/remove border will be not more necessary.

The add/remove borders might still be necessary, i.e. if you resize to mod2, but the resizer requires mod16.
Also, I would rather add and remove borders than resizing and by abiding by a specific mod change the aspect ratio. Only minimal change, but adding and removing borders is fast and should not change the aspect ratio.

Cu Selur

Ps.: I'll look at it, since it should be easy to implement. => correction, is unexpectedly complicated to do this while maintaining the aspect ratio (as good as possible). => after some thinking about it and some calculation, I think it's not really possible without further restrictions.

Forum Jump:

Users browsing this thread: 1 Guest(s)